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。