首页 > 其他 > 详细

索引失效的情况总结

时间:2021-04-06 12:16:34      阅读:23      评论:0      收藏:0      [点我收藏+]
  • A、B两列均存在索引,但 select * from T where A=B;不会走索引,因为全表扫描更快。
  • 存在null值,索引列可空,则不会给其建索引,索引值少于表count值,执行计划会去扫全表,比如 select * from T where id is not null;
  • 反查询,索引定位困难,执行计划更倾向于全表扫描。比如 <>、not in、not exists。
  • 条件包含了函数不会走索引,因为索引在建立时和计算后不同,无法定位索引。 比如 select * from T where upper(name) = "SSS"; 这时可以优化为 select * from T where name = ‘sss‘;
  • 隐式类型转换,比如 select * from T where id = ‘123‘;

以上参考:https://mp.weixin.qq.com/s/JJcDr6jNs7I-RTjUzTAt7g

索引失效的情况总结

原文:https://www.cnblogs.com/smallzhen/p/14620008.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!