① using a composite index (UserName, userage) ② using a composite index (USERAGE,USERNAME)
1.select * from T_user where userName in (' DD ', ' GG ') will use the index under ② without indexing under ①;
2.select * from T_user where userage=3 will not use indexes under ② under ①;
3.select * from T_user where userName like ' saa% ' will use the index under ①
4.select * from T_user where userName like '%saa% ' will not use the index in ①
5.select * from T_user where userage>3 (or between and) will not be indexed under ② using the index under ①②;
6. Use the union ALL operator instead of union because the union all operation simply merges two results and returns. The Union filters out duplicate records, so the resulting set of results is sorted after the table is connected, the duplicate records are deleted, and the results are returned.
7. Replacing > with >=
Whether MySQL uses an indexed instance