mysql解释输出中语句的顺序有什么意义?
这是我正在研究的查询之一的 mysql 解释计划。
+----+-------------+--------+-------+---------------+---------+---------+------+------+-------+
| 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)
此输出中的语句顺序有何意义? 这是否意味着 table5 在所有其他内容之前被读取?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些表按照 MySQL 在处理查询时读取它们的顺序在输出中列出。您可以在此处阅读有关解释计划输出的更多信息。
此外,输出告诉我:
type
列),索引是主键(基于key
列)。另外两个无法使用任何索引。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:
type
column), which were primary keys (based on thekey
column). The other two could not use any indexes.