mysql索引失效
1、联合索引不走最左匹配
2、使用select *
3、索引列参与运算
4、索引列使用函数
5、like使用左%
6、使用隐式转换
7、使用or,但两个字段没有全部使用索引
8、两个列作比较
9、使用is not null \not in \not exists
mysql优化
1、建表时、尽量给默认值,不要设置null
2、使用连接查询来代替子查询
3、给常作为索引的列添加索引
4、使用in来替代or
5、使用union/union all 来代替or
6、少使用不等于、not null 、not exists 判断
7、总之尽量不要让索引失效,有不全或不足请大家评论区留言补充