Mysql精华问答(五)| explain 进行Sql分析

网友投稿 648 2022-11-07

本站部分文章、图片属于网络上可搜索到的公开信息,均用于学习和交流用途,不能代表睿象云的观点、立场或意见。我们接受网民的监督,如发现任何违法内容或侵犯了您的权益,请第一时间联系小编邮箱jiasou666@gmail.com 处理。

Mysql精华问答(五)| explain 进行Sql分析

{EXPLAIN | DESCRIBE | DESC} tbl_name [col_name | wild]{EXPLAIN | DESCRIBE | DESC} [explain_type] {explainable_stmt | FOR CONNECTION connection_id}explain_type: { EXTENDED | PARTITIONS | FORMAT = format_name}format_name: { TRADITIONAL | JSON}explainable_stmt: { SELECT statement | DELETE statement | INSERT statement | REPLACE statement | UPDATE statement}

explain select * from test1 t1 inner join test1 t2 on t1.id=t2.id

结果:

explain select * from test1 t1 where t1.id = (select id from test1 t2 where t2.id=2);

结果:

explain select t1.* from test1 t1inner join (select max(id) mid from test1 group by id) t2on t1.id=t2.mid

结果:

explain select * from test1;

结果:

explain select * from test1 t1 where t1.id = (select id from test1 t2 where t2.id=2);

结果:

explainselect t1.* from test1 t1inner join (select max(id) mid from test1 group by id) t2on t1.id=t2.mid

结果:

explainselect * from test1unionselect* from test2

结果:

explain select * from test2 where id=1;

结果:

explain select * from test2 t1 inner join test2 t2 on t1.id=t2.id;

结果:

explain select * from test2 where code = '001';

结果:

explain select * from test1 t1 inner join test1 t2 on t1.id=t2.id where t1.code='001';

来源 | 捡田螺的小男孩

上一篇:华为openGauss 最佳实践
下一篇:软件测试培训之测试基础
相关文章

 发表评论

暂时没有评论,来抢沙发吧~