I have seen this several times, but I may have misinterpreted the EXPLAIN query plan.
Suppose I have a table (col1, col2). I want to join it with another table on col1 and col2. Therefore, I create an index (col1, col2). Sometimes EXPLAIN indicates that the index is not used. Perhaps some other inefficient index is used or not at all.
But if I create another index (col1), then the first index (col1, col2) is used.
Has this happened to anyone before? Do you have any idea why this might happen?
My theory is that an unused index provides more accurate statistics about a table that alludes to a query plan for using the first index. But I'm not good enough at mysql's inner workings to find out if this is true or how to prove it.
source share