【已解决】关于前缀索引,查询的时候where条件顺序一定要和表结构顺序一样吗?

Viewed 61
create table users (`phone` int,`name` varchar, ...)
select ... where name='john' and phone=1212212

这样能匹配到前缀索引优化吗?

1 Answers

如题目中的描述是可以命中前缀索引的,优化器会自动调整过滤条件顺序

如果过滤条件只有name,那么无法命中前缀索引