Lazy loaded image
学习笔记
MySQL Explain实践
Words 311Read Time 1 min
2025-2-27
2025-3-12
type
status
date
slug
summary
tags
category
icon
password
  1. 全值匹配
    1. notion image
  1. 最左前缀法则
    1. notion image
  1. 不在索引列上做任何操作(计算、函数、(自动or手动)类型转换),会导致索引失效而转向全表扫描
    1. notion image
  1. 存储引擎不能使用索引中范围条件右边的列
    1. notion image
  1. 尽量使用覆盖索引(只访问索引的查询(索引列包含查询列)),减少 select * 语句
    1. notion image
  1. mysql在使用不等于(!=或者<>),not in ,not exists 的时候无法使用索引会导致全表扫描 < 小于、 > 大于、 <=、>= 这些,mysql内部优化器会根据检索比例、表大小等多个因素整体评估是否使用索引
    1. notion image
  1. is null,is not null 一般情况下也无法使用索引
    1. notion image
  1. like以通配符开头('$abc...')mysql索引失效会变成全表扫描操作
    1. notion image
      notion image
      notion image
  1. 字符串不加单引号索引失效
    1. notion image
  1. 少用or或in,用它查询时,mysql不一定使用索引,mysql内部优化器会根据检索比例、表大小等多个因素整体评估是否使用索引,详见范围查询优化
    1. notion image
  1. 范围查询优化
    1. notion image
上一篇
MySQL InnoDB
下一篇
Git