I wanted to share a little rule of thumb I sometimes use to decide which columns should come first in an index. This is not specific to MySQL, it's generally applicable to any database server with b-tree indexes. And there are a bunch of subtleties, but I will also ignore those for the sake of simplicity.
Let's start with this query, which returns zero rows but does a full table scan. EXPLAIN says there are no possible_keys.PLAIN TEXT SQL:
Don't try to figure out the meaning of the query, because that'll[Read more...]