When dealing with multicolumn indexes the order of the columns in the index definition is very important. Fpr example if you have such an index
INDEX (a,b,c)
and you issue a query such
... WHERE b>1000;
MySQL will not be able to use the index. In case ol multicolumn indexes MySQL will always use the left-most part of the index. So, the index will be used for example if the query would be:
... WHERE a>100 AND b>1000;
So, MySQL will use the index only for search conditions that involve the follwing columns:
- a ,b ,c
- a, b
- a
The mulitcolumn indexes are also useful in solving ORDER BY and
GROUP BY operations.
Let’s see the folliwing example.
Here is my customer table (for sake of simplicity it’s just a
subset of my real table).
corra@localhost> show create table customer\G …[Read more]