首页 > 技术文章 > SQL 哪些情况会使索引失效

w-yu-chen 2021-06-22 22:31 原文

 

1、前导like
-- 生效
explain select * from cartoon where `name` like '家里来了位道长大人%'
-- 不生效
explain select * from cartoon where `name` like '%555%'
2、”or”条件
3、“in”条件
4、”<>”条件
5、”between” 范围条件,可使用where xx>1 and xx<3 替代
6、is null 或者 is not null,判断为空
7、不能在索引上做任何操作(计算、函数、自动/手动类型转换)

 

推荐阅读