Actually, I just tried this for the problem I had, and it turns out that it is very important to use the index.
Let's say we have a secondary index in the Customers table with two columns (City, State) - and they are listed in that order in the index.
SELECT COUNT (*) FROM Customer GROUP BY City, EXPLAIN shows that it uses an index.
But...
SELECT COUNT (*) FROM Customer GROUP BY State, City EXPLAIN indicates that it is not using an index.
This is on MySQL 5.1 with an InnoDB table.
Artem Jul 15 '10 at 14:37 2010-07-15 14:37
source share