http://blog.163.com/li_hx/blog/static/183991413201642410122327/

mysql> CREATE TABLE t1 (a INT, b INT);
Query OK, rows affected (0.22 sec) mysql> CREATE TABLE t2 (c INT, d INT);
Query OK, rows affected (0.21 sec) mysql> CREATE TABLE t3 (e INT);
Query OK, rows affected (0.22 sec) mysql> INSERT INTO t1 VALUES (,), (,);
Query OK, rows affected (0.19 sec)
Records: Duplicates: Warnings: mysql> INSERT INTO t2 VALUES (,), (,);
Query OK, rows affected (0.17 sec)
Records: Duplicates: Warnings: mysql> INSERT INTO t3 VALUES (), ();
Query OK, rows affected (0.18 sec)
Records: Duplicates: Warnings:
mysql> select * from t1;
+------+------+
| a | b |
+------+------+
| | |
| | |
+------+------+
rows in set (0.00 sec) mysql> select * from t2;
+------+------+
| c | d |
+------+------+
| | |
| | |
+------+------+
rows in set (0.00 sec) mysql> select * from t3;
+------+
| e |
+------+
| |
| |
+------+
rows in set (0.00 sec)
mysql> EXPLAIN SELECT * FROM t1 WHERE t1.a IN (SELECT c FROM t2 WHERE (SELECT e FROM t3 as t31) < SOME (SELECT e FROM t3 as t32 WHERE t1.b));
+----+--------------------+-------+------+---------------+------+---------+------+------+--------------------------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+--------------------+-------+------+---------------+------+---------+------+------+--------------------------------------------------------------------+
| | PRIMARY | t1 | ALL | NULL | NULL | NULL | NULL | | Using where |
| | PRIMARY | t2 | ALL | NULL | NULL | NULL | NULL | | Using where; FirstMatch(t1); Using join buffer (Block Nested Loop) |
| | DEPENDENT SUBQUERY | t32 | ALL | NULL | NULL | NULL | NULL | | Using where |
| | SUBQUERY | t31 | ALL | NULL | NULL | NULL | NULL | | NULL |
+----+--------------------+-------+------+---------------+------+---------+------+------+--------------------------------------------------------------------+
rows in set (0.00 sec)
mysql> EXPLAIN format=json SELECT * FROM t1 WHERE t1.a IN (SELECT c FROM t2 WHERE (SELECT e FROM t3 as t31) < SOME (SELECT e FROM t3 as t32 WHERE t1.b))\G
*************************** . row ***************************
EXPLAIN: {
"query_block": {
"select_id": ,
"nested_loop": [
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": ,
"filtered": ,
"attached_condition": "<nop>(<in_optimizer>((/* select#3 */ select `test`.`t31`.`e` from `test`.`t3` `t31`),<exists>(/* select#4 */ select 1 from `test`.`t3` `t32` where (`test`.`t1`.`b` and <if>(outer_field_is_not_null, ((<cache>((/* select#3 */ select `test`.`t31`.`e` from `test`.`t3` `t31`)) < `test`.`t32`.`e`) or isnull(`test`.`t32`.`e`)), true)) having <if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t32`.`e`), true))))",
"attached_subqueries": [
{
"dependent": true,
"cacheable": false,
"query_block": {
"select_id": ,
"table": {
"table_name": "t32",
"access_type": "ALL",
"rows": ,
"filtered": ,
"attached_condition": "(`test`.`t1`.`b` and <if>(outer_field_is_not_null, ((<cache>((/* select#3 */ select `test`.`t31`.`e` from `test`.`t3` `t31`)) < `test`.`t32`.`e`) or isnull(`test`.`t32`.`e`)), true))"
}
}
},
{
"dependent": false,
"cacheable": true,
"query_block": {
"select_id": ,
"table": {
"table_name": "t31",
"access_type": "ALL",
"rows": ,
"filtered":
}
}
}
]
}
},
{
"table": {
"table_name": "t2",
"access_type": "ALL",
"rows": ,
"filtered": ,
"first_match": "t1",
"using_join_buffer": "Block Nested Loop",
"attached_condition": "(`test`.`t2`.`c` = `test`.`t1`.`a`)"
}
}
]
}
}
row in set, warnings (0.00 sec)
mysql> SHOW WARNINGS\G
*************************** . row ***************************
Level: Note
Code:
Message: Field or reference 'test.t1.b' of SELECT # was resolved in SELECT #
*************************** . row ***************************
Level: Note
Code:
Message: /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where ((`test`.`t2`.`c` = `test`.`t1`.`a`) and <nop>(<in_optimizer>((/* select#3 */ select `test`.`t31`.`e` from `test`.`t3` `t31`),<exists>(/* select#4 */ select from `test`.`t3` `t32` where (`test`.`t1`.`b` and <if>(outer_field_is_not_null, ((<cache>((/* select#3 */ select `test`.`t31`.`e` from `test`.`t3` `t31`)) < `test`.`t32`.`e`) or isnull(`test`.`t32`.`e`)), true)) having <if>(outer_field_is_not_null, <is_not_null_test>(`test`.`t32`.`e`), true)))))
rows in set (0.00 sec)

DEPENDENT SUBQUERY” 和 “SUBQUERY”的更多相关文章

  1. [慢查优化]慎用MySQL子查询,尤其是看到DEPENDENT SUBQUERY标记时

    案例梳理时间:2013-9-25 写在前面的话: 在慢查优化1和2里都反复强调过 explain 的重要性,但有时候肉眼看不出 explain 结果如何指导优化,这时候还需要有一些其他基础知识的佐助, ...

  2. 看懂mysql执行计划--官方文档

    原文地址:https://dev.mysql.com/doc/refman/5.7/en/explain-output.html 9.8.2 EXPLAIN Output Format The EXP ...

  3. [MySQL Reference Manual] 8 优化

    8.优化 8.优化 8.1 优化概述 8.2 优化SQL语句 8.2.1 优化SELECT语句 8.2.1.1 SELECT语句的速度 8.2.1.2 WHERE子句优化 8.2.1.3 Range优 ...

  4. Mysql DOC阅读笔记

    Mysql DOC阅读笔记 转自我的Github Speed of SELECT Statements 合理利用索引 隔离调试查询中花费高的部分,例如函数调用是在结果集中的行执行还是全表中的行执行 最 ...

  5. MySQL库表状态查询

    一. 查看库的各链接状态 对于一个mysql连接或者一个线程,任何时刻都有一个状态,表示其当前正在做什么.一般使用show full processlist查看. +---------+------- ...

  6. 【mysql】mysql 调优之 ——执行计划 explain

    1.what is explain(explain 是个什么东东) explain(解释),在 Mysql 中 作为一个关键词,用来解释 Mysql 是如何执行语句,可以连接 select .dele ...

  7. Mysql的性能优化

    1.参考书籍:MYSQL 5.5从零开始学 Mysql性能优化就算通过合理安排资源,调整系统参数使MYSQL运行更快,更节省资源.MYSQL性能优化包括查询速度优化,更新速度优化,mysql服务器优化 ...

  8. oracle已知会导致错误结果的bug列表(Bug Issues Known to cause Wrong Results)

    LAST UPDATE:     1 Dec 15, 2016 APPLIES TO:     1 2 3 4 Oracle Database - Enterprise Edition - Versi ...

  9. MySQL优化之Explain命令解读,optimizer_trace

    简述: explain为mysql提供语句的执行计划信息.可以应用在select.delete.insert.update和place语句上.explain的执行计划,只是作为语句执行过程的一个参考, ...

随机推荐

  1. ab基本用法

    ab的全称是ApacheBench,是 Apache 附带的一个小工具,专门用于 HTTP Server 的benchmark testing,可以同时模拟多个并发请求.前段时间看到公司的开发人员也在 ...

  2. Android PackageManager packages.xml文件格式

    packages.xml文件存放在/data/system目录下    该文件记录了系统中所有应用程序的包管理相关信息    PmS根据该文件进行包管理的各种操作 标签名称 所包含的值举例 last- ...

  3. In Place Upgrade of CentOS 6 to CentOS 7

    Note: This is not the most highly recommended method to move from CentOS 6 to CentOS 7 ... but it ca ...

  4. "The connection for the USB device '###' was unsuccessful. The device is currently in use"

    一.问题描述 1.情景描述 笔者的物理主机系统是“windows7 64位”,想使用“摄像头录像大师”.这个软件在录制视频的过程中,需要调用windows自带的"windows media ...

  5. gcc/g++编译

    1. gcc/g++在执行编译工作的时候,总共需要4步 (1).预处理,生成.i的文件[预处理器cpp] (2).汇编,将预处理后的文件转换成汇编语言,生成文件.s[编译器egcs] (3).编译,将 ...

  6. jQuery设置按钮被点击状态

    js和jquery如何使按钮失效,很简单,只要设置disabled属性为true即为不可用状态即可 1.JS方法一: document.getElementByIdx("btn") ...

  7. [BZOJ 1500] [NOI2005] 维修数列

    题目链接:BZOJ - 1500 题目分析 我要先说一下,这道题我写了一晚上,然后Debug了一整个白天..........再一次被自己的蒟蒻程度震惊= = 这道题是传说中的Splay维护数列的Bos ...

  8. c# 函数练习;结构体、枚举类型

       * 结构体 1.就是一个自定义的集合,里面可以放各种类型的元素,用法大体跟集合一样. 注意:枚举类型和结构体都属于值类型. 2.定义的方法: struct student { public in ...

  9. Android 中LocalBroadcastManager的使用方式

    Android 中LocalBroadcastManager的使用方式 在android-support-v4.jar中引入了LocalBroadcastManager,称为局部通知管理器,这种通知的 ...

  10. 【HDOJ】2780 Su-Su-Sudoku

    模拟+DFS. /* 2780 */ #include <cstdio> #include <cstring> #include <cstdlib> ][]; ][ ...