开发者

What is the significance of the order of statements in mysql explain output?

This is mysql explain plan for one of the query I am looking into.

+----+开发者_如何学运维-------------+--------+-------+---------------+---------+---------+------+------+-------+
| id | select_type | table  | type  | possible_keys | key     | key_len | ref  | rows | Extra |
+----+-------------+--------+-------+---------------+---------+---------+------+------+-------+
|  1 | SIMPLE      | table2 | index | NULL          | PRIMARY | 4       | NULL |    6 |       | 
|  1 | SIMPLE      | table3 | ALL   | NULL          | NULL    | NULL    | NULL |   23 |       | 
|  1 | SIMPLE      | table1 | ALL   | NULL          | NULL    | NULL    | NULL |    8 |       | 
|  1 | SIMPLE      | table5 | index | NULL          | PRIMARY | 4       | NULL |    1 |       | 
+----+-------------+--------+-------+---------------+---------+---------+------+------+-------+

4 rows in set (0 sec)

What is the significance of the order of statements in this output ? Does it mean that table5 is read before all others ?


The tables are listed in the output in the order that MySQL would read them while processing the query. You can read more about the Explain plan output here.

Additionally, the output tells me:

  • The optimizer saw the query as having four (4) SELECT statements within it. Being a "simple" select type, those queries are not using UNION or subqueries.
  • Two of those statements could use indexes (based on the type column), which were primary keys (based on the key column). The other two could not use any indexes.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜