Jump to content

Noob Database Index Question


Recommended Posts

Why is it important to have an Index in my MySQL database.  I am just messing around and PMA has this error on the structure page that says "No Index Defined".

 

 

Can somebody explain why having an Index is so important?  I do understand that it makes searching quicker. 

Link to comment
Share on other sites

I do understand that it makes searching quicker.

 

That's an understatement.  Imagine you have a 500 page programming book, and you're asked to find every occurrence of the word "variable".  If the book did not have an index would have to look at every word from page 1 to 500.  The same holds true with a table in a schema.  Imagine you have a table with n rows and you are looking for all rows where column_a = "variable", if the column is not indexed  the rdbms has to look at every row in the table.  This becomes more and more expensive as a function of n.  If you have an index on that column, just as in the book example, the rdbms knows where to look in order to find the rows where column_a = "variable".

 

Best,

 

Patrick

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.