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. JS-运动框架

    写这段代码,是因为之前看过某前RD写过,但在测试过程中发现有不完美的地方. 问题在于判断运动停止条件这里,对于之前停止的判断太片面,只能判断一个条件值时的情况,对于多条件时,会发现运动后的各项值并未达 ...

  2. 扩展原生js的一些方法

    扩展原生js的Array类 Array.prototype.add = function(item){ this.push(item); } Array.prototype.addRange = fu ...

  3. vbox里面的Ubuntu虚拟机与主机win7之间设置共享文件夹

    有时候我们希望虚拟机和主机之间进行通信,例如传一些文件.那么设置共享文件夹就是一种很好的方式. 这里我的主机是win7系统,vbox里面的虚拟机是Ubuntu. 1.首先安装vbox的VBOXGues ...

  4. linux socket使用经验总结

    1.  scoket函数中PF_INET AF_INET区别 在UNIX系列中,PF_INET表示poxis, BSD系列用AF_INET 2.  in_addr_t inet_addr(const ...

  5. seajs 和spm的使用简介

    说实话, 前端开发是一个令人头痛的事情. nodejs出现了很久了, 一直不是很习惯用nodejs, 当初刚出来的时候, 就下载了express, 想搭建个网站, 结果不是我的菜, 愣是用的不习惯,也 ...

  6. dispatch队列

    GCD编程的核心就是dispatch队列,dispatch block的执行最终都会放进某个队列中去进行,它类似NSOperationQueue但更复杂也更强大,并且可以嵌套使用.所以说,结合bloc ...

  7. 【Itext】解决Itext5大并发大数据量下输出PDF发生内存溢出outofmemery异常

    尼玛,这个问题干扰了我两个星期!! 关键字 itext5 outofmemery 内存溢出 大数据 高并发 多线程 pdf 导出 报表 itext 并发 在读<<iText in Acti ...

  8. Android 使用HTTP(get和post)方式登陆服务器

    package com.wuyou.submittoserver; import android.os.Bundle; import android.support.v7.app.ActionBarA ...

  9. lc面试准备:Reverse Linked List II

    1 题目 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1 ...

  10. python 正则表达式(一)

    正则表达式(regular exprssion)是一种形式化语法描述的文本匹配模式.模式被解释为一组指令,然后会执行这组指令.以一个字符串作为输入,生成一个匹配的子集或源字符串的修改版本. 表达式可以 ...