select distinct ... from ... join ... on ... where ... group by ... having ... order by ... limit ... 解析过程
from ... on ... join ... where ... group by ... having ... select distinct ... order by ... limit ... 因此我怀疑是联合索引建的顺序问题,导致触发索引的效果不好。are you sure?试一下就知道了。
alter table student add index student_union_index2(age,sex,name); 删除旧的不用的索引:
drop index student_union_index on student 索引改名
ALTER TABLE student RENAME INDEX student_union_index2 TO student_union_index 更改索引顺序之后,发现type级别发生了变化,由index变为了range。