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'
)
)
);
Mysql查看优化后的SQL 语句的更多相关文章
- 两种方式:mysql查看正在执行的sql语句
mysql查看正在执行的sql语句 2015年08月21日 17:32:59 阅读数:15398 有2个方法: 1.使用processlist,但是有个弊端,就是只能查看正在执行的sql语句,对应 ...
- Mysql性能优化一:SQL语句性能优化
这里总结了52条对sql的查询优化,下面详细来看看,希望能帮助到你 1, 对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2,应尽量避免在 w ...
- mysql查看正在执行的sql语句
有2个方法: 1.使用processlist,但是有个弊端,就是只能查看正在执行的sql语句,对应历史记录,查看不到.好处是不用设置,不会保存. -- use information_schema; ...
- MySQL数据库优化技术之SQL语句慢查询定位
通过show status命令了解各种SQL的执行频率 MySQL客户端连接成功后,通过使用show [session|global] status 命令可以提供服务器状态信息: 其中的session ...
- 解决Mysql搭建成功后执行sql语句报错以及区分大小写问题
刚搭建完mysql 8.0以后会: 一.表区分大小写, 二.执行正确的sql语句成功且会报:[Err] 1055 - Expression #1 of ORDER BY clause is not i ...
- Mysql查看锁等信息SQL语句
查看锁等信息,包括锁信息: select "HOLD:",ph.id h_processid,trh.trx_id h_trx_id,trh.trx_started h_start ...
- mysql 优化(包含sql语句的书写)
http://blog.chinaunix.net/uid-11640640-id-3426908.html mysql性能优化-慢查询分析.优化索引和配置 2012-11-30 15:18:42 ...
- 《MySQL慢查询优化》之SQL语句及索引优化
1.慢查询优化方式 服务器硬件升级优化 Mysql服务器软件优化 数据库表结构优化 SQL语句及索引优化 本文重点关注于SQL语句及索引优化,关于其他优化方式以及索引原理等,请关注本人<MySQ ...
- 如何查找MySQL中查询慢的SQL语句
如何查找MySQL中查询慢的SQL语句 更多 如何在mysql查找效率慢的SQL语句呢?这可能是困然很多人的一个问题,MySQL通过慢查询日志定位那些执行效率较低的SQL 语句,用--log-slow ...
随机推荐
- 使用vue-cli3搭建项目过程
一.搭建前准备 node.js版本为8.9+: 安装模块:npm install -g n // 安装模块 这个模块是专门用来管理node.js版本的: 若原先已经安装,则更细模块:n stable ...
- LeetCode 1102. Path With Maximum Minimum Value
原题链接在这里:https://leetcode.com/problems/path-with-maximum-minimum-value/ 题目: Given a matrix of integer ...
- inflection point
http://blog.thefirehoseproject.com/posts/learn-to-code-and-be-self-reliant/ kill will develop 1.repe ...
- LOJ P10016 灯泡 题解
每日一题 day50 打卡 Analysis 用初中学的相似推一波式子,再用三分一搞就好了. #include<iostream> #include<cstdio> #incl ...
- isntall
#! /bin/bash # zabbix server address zabbix='10.10.238.110' # repo address REPO='10.10.238.114:4507' ...
- 微信小程序地图组件
index.wxml <map id="map" markers="{{markers}}" longitude="{{longitude}}& ...
- 在GitHub上使用Hexo 搭建自己的博客
1.下载Node.js安装文件(现在电脑基本都是64位的,我就放64位的下载地址):https://nodejs.org/dist/v8.9.4/node-v8.9.4-x64.msi 或者自行到官网 ...
- pdfBox 解析 pdf文件
Spting boot 项目 1.添加依赖 <dependency> <groupId>org.apache.pdfbox</groupId> <artifa ...
- C#构建可扩展的应用程序(插件)
构建可扩展的应用程序,特别是对于WinForm应用程序是特别有好处的.我们知道,企业的需求是瞬息万变的,企业在使用软件的过程中,很可能对于现有的需求有变动甚至是提出新的需求来,可是我们的软件已经部署在 ...
- crontab定时任务接入
# 查看 $ crontab -l # 创建 $ crontab -e # 每分钟输出一次当前时间 * * * * * echo `date` >> /demo.log # 查看定时 $ ...