Mysql查看优化后的SQL 语句
时间:2019-11-27
本文章向大家介绍Mysql查看优化后的SQL 语句,主要包括Mysql查看优化后的SQL 语句使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
EXPLAIN EXTENDED
1先执行 EXPLAIN EXTENDED
2 show warnings;
EXPLAIN EXTENDED SELECT * FROM `receivable_application_relation` d WHERE d.`application_id` IN (SELECT id FROM application WHERE application_code IN ( 'ZYHT20190305192721001', 'ZYHT20190309152839001', 'ZYHT20190309152904001' ));
SHOW WARNINGS;
查看优化后最终执行的sql
In 并不是走的子查询 而是 join ,这个是 从上面的画红线的地方copy 出来的
SELECT `cf_receivables_financing`.`d`.`id` AS `id`, `cf_receivables_financing`.`d`.`application_id` AS `application_id`, `cf_receivables_financing`.`d`.`receivable_id` AS `receivable_id`, `cf_receivables_financing`.`d`.`update_time` AS `update_time`, `cf_receivables_financing`.`d`.`create_time` AS `create_time`, `cf_receivables_financing`.`d`.`deleted` AS `deleted` FROM `cf_receivables_financing`.`application` JOIN `cf_receivables_financing`.`receivable_application_relation` `d` WHERE ( ( `cf_receivables_financing`.`d`.`application_id` = `cf_receivables_financing`.`application`.`id` ) AND ( `cf_receivables_financing`.`application`.`application_code` IN ( 'ZYHT20190305192721001', 'ZYHT20190309152839001', 'ZYHT20190309152904001' ) ) )
EXPLAIN EXTENDED SELECT d.* FROM `receivable_application_relation` d INNER JOIN application a ON d.`application_id` = a.id WHERE a.application_code IN ( 'ZYHT20190305192721001', 'ZYHT20190309152839001', 'ZYHT20190309152904001' );
查看优化后的sql
SELECT `cf_receivables_financing`.`d`.`id` AS `id`, `cf_receivables_financing`.`d`.`application_id` AS `application_id`, `cf_receivables_financing`.`d`.`receivable_id` AS `receivable_id`, `cf_receivables_financing`.`d`.`update_time` AS `update_time`, `cf_receivables_financing`.`d`.`create_time` AS `create_time`, `cf_receivables_financing`.`d`.`deleted` AS `deleted` FROM `cf_receivables_financing`.`receivable_application_relation` `d` JOIN `cf_receivables_financing`.`application` `a` WHERE ( ( `cf_receivables_financing`.`d`.`application_id` = `cf_receivables_financing`.`a`.`id` ) AND ( `cf_receivables_financing`.`a`.`application_code` IN ( 'ZYHT20190305192721001', 'ZYHT20190309152839001', 'ZYHT20190309152904001' ) ) );
原文地址:https://www.cnblogs.com/fanBlog/p/11943748.html
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解
- mybatis-spring 启动过程和调用过程
- Spring实现事务管理
- ES6深入浅出-2 新版函数:3 三个点运算 & 新版字符串-1.函数与对象的语法糖
- 严选好物,严选小程序
- 简单CSS实现闪烁动画(+1白话讲解)
- java中代码块,方法与构造器的执行顺序。
- 正则表达式--捕获组
- 【BZOJ3545 & LGOJ4197】Peaks(Kruskal重构树 主席树)
- jquery实现输入框实时统计字数和设置字数限制功能
- .net core web api 添加对session跨域实现
- 09
- 汇总:ASP.NET Core中HttpContext获取传参数据,有哪些方式
- MarkDown富文本编辑器怎么加载模板文件
- 干货:.net core实现读取appsettings.json配置文件(建议收藏)
- python语法学习第十一天--迭代器