MySQL Explain详解
2008-09-03 11:09:02 来源:WEB开发网(4).DEPENDENT union
union中的第二个或后面的select语句,取决于外面的查询
mysql>explainselect*fromt3whereidin(selectidfromt3whereid=3952602unionallselectidfromt3);
+----+--------------------+------------+--------+-------------------+---------+---------+-------+------+--------------------------+
|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
+----+--------------------+------------+--------+-------------------+---------+---------+-------+------+--------------------------+
|1|PRIMARY|t3|ALL|NULL|NULL|NULL|NULL|1000|Usingwhere|
|2|DEPENDENTSUBQUERY|t3|const|PRIMARY,idx_t3_id|PRIMARY|4|const|1|Usingindex|
|3|DEPENDENTunion|t3|eq_ref|PRIMARY,idx_t3_id|PRIMARY|4|func|1|Usingwhere;Usingindex|
|NULL|unionRESULT||ALL|NULL|NULL|NULL|NULL|NULL||
+----+--------------------+------------+--------+-------------------+---------+---------+-------+------+--------------------------+
(5).union RESULT
union的结果。
mysql>explainselect*fromt3whereid=3952602unionallselect*fromt3;
+----+--------------+------------+-------+-------------------+---------+---------+-------+------+-------+
|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
+----+--------------+------------+-------+-------------------+---------+---------+-------+------+-------+
|1|PRIMARY|t3|const|PRIMARY,idx_t3_id|PRIMARY|4|const|1||
|2|union|t3|ALL|NULL|NULL|NULL|NULL|1000||
|NULL|unionRESULT||ALL|NULL|NULL|NULL|NULL|NULL||
+----+--------------+------------+-------+-------------------+---------+---------+-------+------+-------+
更多精彩
赞助商链接