What is database indexing and primary keys?

Category: Databases

stu
Asked:
2012-02-29 11:22 pm EST

Hits: 2,792
I'm trying to check my tables to see why my DB is acting slow and I get this message:

The indexes PRIMARY and id seem to be equal and one of them could possibly be removed.

I don't have a column called Primary, though I have one called ID.

You must login before you can ask a follow up question.

You must login before you can submit an answer.

OTHER ANSWERS

0

Tim S.
Staff
9,967 Points
2012-03-01 8:33 am EST
Hi stu,

Thanks for posting your question. I'm more than happy to assist you today. PRIMARY is a reference to the primary key for the table. A PRIMARY KEY is a field or column on the table, when each row is inserted it must be unique. Since it must be unique, it should not exist in the table anywhere else.

To speed up the process, MySQL creates indexes for such fields, so they can quickly detect if a value already exists in the field, without having to check every row in the table itself.

So manually creating indexes on fields already set to PRIMARY KEY or UNIQUE is redundant and can cause performance issues due to the duplication in the indexes.

Did you create one of these unique fields in the table yourself? That is likely the cause since there's already a primary key set and it is being indexed. Typically, you can remove the duplicate field.

I hope this explanation of primary keys and indexes helps you. If you need further assistance please feel free to contact us.

Thanks!

Tim S

You must login before you can post a comment about this answer.

Like this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!