B.5.5 Optimizer-Related Issues

MySQL uses a cost-based optimizer to determine the best way to
resolve a query. In many cases, MySQL can calculate the best
possible query plan, but sometimes MySQL does not have enough
information about the data at hand and has to make
“educated” guesses about the data.

For the cases when MySQL does not do the "right" thing, tools
that you have available to help MySQL are:

Use the EXPLAIN statement to
get information about how MySQL processes a query. To use
it, just add the keyword
EXPLAIN to the front of your
SELECT statement: