InMotion Hosting Support Center

What is database indexing and primary keys?

Category: Databases

2012-02-29 11:22 pm EST

Hits: 3,103
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.



Tim S
13,821 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.


Tim S

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

Like this Question?

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

Social Media Login

Social Login Joomla

Need more Help?


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:
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!