I almost didn’t write on this topic. There are a lot of people out there who know more about indexing than I do. The problem is all of the knowledge on the subject is being presented by and for database specialists. While their need is probably greater, I contend that web programmers who create dynamic sites need this information as well. So I’m going to share what I’ve learned to make my queries faster over the years. If there are any gaping holes of information, than hopefully those will get addressed in the comments.
An index is created on a particular table in your database. You specify one or more columns that you’d like included in the index, and the database then has a snapshot of what the table looks like when all the records are sorted on those columns. The idea is that the table will be able to return query results involving those columns more quickly. Here’s how it works.
Read the rest of this entry »