mysql 执行计划-链接类型type 分析

2021-06-30  本文已影响0人  程序男保姆

1 system 好像数据库只有一条才会出现

2 const 主键or 唯一索引查询


主键查询
explain

select * from student where id  = 1
image.png
唯一索引查询
UNIQUE KEY `name-key` (`name`) USING BTREE

explain
select * from student where name  = '1'
image.png

3 eq-ref

4 ref 普通索引


KEY `name-key` (`name`) USING BTREE

explain
select * from student where name  =  '我是一个美国人'
image.png

5 ref-or-null

6 index-merge

7 index_subquery

8 range

普通索引或者唯一索引  like查询
KEY `name-key` (`name`) USING BTREE

explain
select * from student where name  like  '我是一个美国人%'
image.png

9 index

10 all 全表扫描

explain
select * from student 
image.png
上一篇 下一篇

猜你喜欢

热点阅读