MySQL version 5.6 did not add index condition pushdown before, so the index logic is still like this:
Even for a compound index, start from the first column to determine the index range of the first column. If the range has an = sign, then for the = sign case, determine the index range of the second column and add it to the index result set. How to process each column It's all the same.
After determining the index range, return the table to query the data, and then use the remaining where conditions to filter and judge.
ICP was added after mysql5.6. After the index range is determined, the remaining where conditions will be used to filter the index range again, and then the table will be returned, and the remaining where conditions will be used for filtering judgment. (Reduce the number of records returned to the table).
In addition, I estimate that the amount of your test data should not be large. Otherwise, if the proportion of the index range you determine is too large in the total number of records, the entire table query will not use the index.
MySQL version 5.6 did not add index condition pushdown before, so the index logic is still like this:
Even for a compound index, start from the first column to determine the index range of the first column. If the range has an = sign, then for the = sign case, determine the index range of the second column and add it to the index result set. How to process each column It's all the same.
After determining the index range, return the table to query the data, and then use the remaining where conditions to filter and judge.
ICP was added after mysql5.6. After the index range is determined, the remaining where conditions will be used to filter the index range again, and then the table will be returned, and the remaining where conditions will be used for filtering judgment. (Reduce the number of records returned to the table).
In addition, I estimate that the amount of your test data should not be large. Otherwise, if the proportion of the index range you determine is too large in the total number of records, the entire table query will not use the index.
Probably the amount of your test data is too small, so there is no point in caring about whether the index is used.
Put 100,000 pieces of data and try again
One more note:
When MySQL once estimates that the number of rows to be checked may be "too many", the range search optimization will not be used.