Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
This topic is actually spread throughout most of the book, but we’ll mention a few highlights:
Make sure there are indexes on the columns in the ON or USING clauses. Consider the join order
when adding indexes. If you’re joining tables A and B
on column c and the query
optimizer decides to join the tables in the order B, A,
you don’t need to index the column on table B. Unused indexes are extra overhead. In
general, you need to add indexes only on the second table in the
join order, unless they’re needed for some other reason.
Try to ensure that any GROUP
BY or ORDER BY
expression refers only to columns from a single table, so MySQL can
try to use an index for that operation.