| dependent subquery: 子查询中的第一个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 | +----+--------------------+------------+--------+---------------+---------+---------+-------+-------+-----------------+ 
 derived: 用于from子句中有子查询的情况,mysql会递归执行这些子查询,此结果集放在临时表中 mysql> explain select * from (select * from test2 where id = 1000)a; +----+-------------+------------+--------+---------------+---------+---------+-------+------+-------+ | id | select_type | table      | type   | possible_keys | key     | key_len | ref   | rows | Extra | +----+-------------+------------+--------+---------------+---------+---------+-------+------+-------+ |  1 | PRIMARY     | <derived2> | system | NULL          | NULL    | NULL    | NULL  |    1 | NULL  | |  2 | DERIVED     | test2      | const  | PRIMARY       | PRIMARY | 8       | const |    1 | NULL  | +----+-------------+------------+--------+---------------+---------+---------+-------+------+-------+ 3、table 
 3、table table用来表示输出行所引用的表名 4、type(重要) type表示访问类型,下面依次解释各种类型,类型顺序从最好到最差排列 (编辑:南平站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |