MySQL cannot use a composite index in a lookup in which the WHERE
condition doesn't include the columns forming a left-most prefix:
MySQL cannot use the index to perform lookups if the columns do not form a leftmost prefix of the index.
A quote from this answer on PostgreSQL caught my attention:
This is somewhat different in Oracle 11 which can sometimes also use columns that are not at the beginning of the index definition.
Under what circumstances can Oracle (at least in 11g) do a lookup without the left-most prefix columns existing in the query?
Best Answer
Loosely speaking, the CBO may choose to:
This is what is called a 'skip scan' in Oracle terminology. Skip scans work best when the number of possible values in step (1) is relatively small (that is small compared to the size of the index)
Oracle will use statistics to get an estimate of the cardinality of step (1) before weighing up if performing that many range scans will cost more than just scanning the whole index sequentially