如何查看 sql 的索引使用情况
explain select * from xxx where xxx
索引失效的情况
- 索引选择性太差(搜索出来结果/总量> 1/4 )
- <>/not in 无法使用索引
- is null 会使用索引 is not null 不会使用索引
- where 子句跳过左侧索引列,直接查询右侧索引字段(联合索引时,一定要按从左到右的时候,没有按照从左到右的顺序)
- 对索引使用计算或者使用函数
--- 未完待续
explain select * from xxx where xxx
--- 未完待续
评论