Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.8k views
in Technique[技术] by (71.8m points)

select a,d 为什么不直接走聚集索引?而是全表扫描【innodb引擎】

表里有字段 a,b,c,d

现有联合索引(a,b,c),唯一索引 (d)

select a,d frm student;
explain 查看执行计划,type=all

这是因为觉得直接通过聚集索引去获取a,d的字段比较繁琐,直接用全表扫描去获取吗?

跟select * from student 一样的原理吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

走不走索引主要看 where 涉及的字段,不是看 select 涉及的字段


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...