目前有组合索引 index_3 (phone,age);
explain
select age from app_user
where phone in ('18595910055','18105156925','18634791357')
group by age having count(age) >= 3;
看到有Using temporary,并且单phone索引字段key_len也是63,也就是说索引可能没有走age这个字段
有没有好兄弟解答一下为啥,去掉having也是一样的结果
你定义两个单独的索引试试
不要没事老搞组合索引
你索引建的有问题呢,需要调整索引创建的逻辑
并且单phone索引字段key_len也是63,,你能确定这没走联合索引么