首页 > 数据库技术 > 详细

MySQL 索引小结

时间:2019-07-07 00:12:10      阅读:110      评论:0      收藏:0      [点我收藏+]

1、!=、not in

在primary key上使用 !=、not in,explain 的 type 是 range,非primary key是全表扫描

2、and、or

多个字段有单独的索引时,会用到index merge,索引合并

or 无法使用联合索引,and 可以

使用 or 会导致全表扫描时,用 union、in替换,可能会使用到索引,或者效率更高

3、null

单列、联合索引,is null 会走索引,is not null 不会走索引

null 会多占空间,count不会统计null行,对null做运算的结果都是null

 

MySQL 索引小结

原文:https://www.cnblogs.com/linguoguo/p/11144663.html

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