美文网首页
mysql 执行计划-链接类型type 分析

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

作者: 程序男保姆 | 来源:发表于2021-06-30 10:08 被阅读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

相关文章

网友评论

      本文标题:mysql 执行计划-链接类型type 分析

      本文链接:https://www.haomeiwen.com/subject/bpalultx.html