| dependent union: union中的第二个或随后的select查询,依赖于外部查询的结果集 mysql> explain select * from test where id in (select id  from test where id = 1000 union all select id from test2) ; +----+--------------------+------------+--------+---------------+---------+---------+-------+-------+-----------------+ | id | select_type        | table      | type   | possible_keys | key     | key_len | ref   | rows  | Extra           | +----+--------------------+------------+--------+---------------+---------+---------+-------+-------+-----------------+ |  1 | PRIMARY            | test       | ALL    | NULL          | NULL    | NULL    | NULL  | 68505 | Using where     | |  2 | DEPENDENT SUBQUERY | test       | const  | PRIMARY       | PRIMARY | 8       | const |     1 | Using index     | |  3 | DEPENDENT UNION    | test2      | eq_ref | PRIMARY       | PRIMARY | 8       | func  |     1 | Using index     | | NULL | UNION RESULT       | <union2,3> | ALL    | NULL          | NULL    | NULL    | NULL  |  NULL | Using temporary | +----+--------------------+------------+--------+---------------+---------+---------+-------+-------+-----------------+ 
 subquery: 子查询中的第一个select查询,不依赖与外部查询的结果集 mysql> explain select * from test where id = (select id from test where id = 1000); +----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+ | id | select_type | table | type  | possible_keys | key     | key_len | ref   | rows | Extra       | +----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+ |  1 | PRIMARY     | test  | const | PRIMARY       | PRIMARY | 8       | const |    1 | NULL        | |  2 | SUBQUERY    | test  | const | PRIMARY       | PRIMARY | 8       | const |    1 | Using index | +----+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+ 
 (编辑:南平站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |