学习笔记(11):MySQL版SQL优化-Extra字段

立即学习:https://edu.csdn.net/course/play/25283/297147?utm_source=blogtoedu

(ii)using  temporary 性能损耗大,用到了临时表。一般出现在group by 语句中,已经有表了,但不适用,必须再来一张表。解析过程:

 from .. on ..join .. where .. group by ...having ...select dinstinct ..order by limit ...

a.explain select * from test03 where a2=2 and a4=4 group by a2,a4;  ---没有 using  temporary

b.explain select * from test03 where a2=2 and a4=4 group by a3;   ---有 using  temporary

总结:i.如果(a,b,c,d)复合索引  和使用的顺序全部一致(且不跨列使用),则复合索引全部使用。

(iii) using index:性能提升;索引覆盖(覆盖索引)。原因:不读取原文件,只从索引文件中获取数据(不需要回表查询)

如果用到了索引覆盖(using index时),会对possible_keys和key造成影响;

a.如果没有where,则索引只出现在key中;

b.如果有where,则索引出现在key和possible_keys中

(iii).using where  (需要回表查询)

(iv)impossible where:where子句永远为false

发布了15 篇原创文章 · 获赞 4 · 访问量 632

猜你喜欢

转载自blog.csdn.net/ankang_66/article/details/104353970