MySQL中的专业名词

MySQL中的专业名词

假设一张表

id 主键 name 普通索引 age 普通索引

回表

select * from user where name ="ls",
第一次查询name为b+树,根据name获取到id主键,再根据id去id获取B+树上找到行记录,
这个过程叫回表
效率不高,因为io的次数变多

索引覆盖

select id,name  from user where name ="ls",
在进行检索的时候,直接根据name去获取name中B+树上的id,name两个别的值,此时不需要回表,效率高,
应尽可能的多使用索引覆盖来代替回表。在负责的sql中,可以考虑不相关的列,都设置索引列

最左匹配

假如 name和age为联合索引
123 会使用
select id,name,age  from user where name =?,
select id,name,age  from user where name =? and age = ?,
select id,name,age  from user where age =? and name = ?, 优化器会调整顺序
select id,name,age  from user where age = ?,

索引下推

select id,name,age  from user where name =? and age = ?,
在没有索引下推之前,先根据name去存储引擎中拉取符合结果的数据,返回到server层,
在server层中对age进行过滤
有了索引下推之后,根据name,age两个条件直接从储存引擎中拉去结果,不需要在server进行过滤
mysql5.7以后自动开启

原文地址:https://www.cnblogs.com/wsycoo/p/15018985.html