Skip to main content
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : Web Architecture : Education - Tutorials
Writing efficient PHP
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
4. Optimizing database queries

Considering indexes page 6 of 8

With most database engines, you can execute queries manually at the equivalent of a command-line. The database engine will show you which indexes, if any, it used when executing the query. Try this with some of your longer running queries. You may be surprised at the results.

In some cases, even though various indexes may exist on a table, the database engine may not be able to use them for your particular type of query. Consider the pros and cons of adding another index to this table.

As a general rule of thumb, try to create simple indexes (indexes on just one field in a table). Simple indexes are often more useful to the query engine than more complex, compound indexes. Additionally, the simple indexes typically require less maintenance overhead for the database engine used.

Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact