我在下面有一个解释结果,问题是如何计算检查的总行数?请解释一下这个细节~(先问问题~如有错误,请指正,我将不胜感激)
id select_type type possible_keys key_len rows
1 PRIMARY ALL 1423656
1 PRIMARY eq_ref PRIMARY 8 1
1 PRIMARY ref 152 1
1 PRIMARY ALL 138
1 PRIMARY ALL 1388
1 PRIMARY ALL 1564
3 DERIVED ALL 1684
3 DERIVED eq_ref PRIMARY 8 1
2 DERIVED ALL 141
最佳答案
来自手册:https://dev.mysql.com/doc/refman/5.7/en/explain-output.html
rows (JSON name: rows)
The rows column indicates the number of rows MySQL believes it must examine to execute the query.
For InnoDB tables, this number is an estimate, and may not always be exact.
您的一张表的数字非常高,为 140 万,但 possible_keys
列为空。这意味着这是一个迫切需要建立索引的表。
要检查大量行,就是这样。 Mysql 需要读取所有这些行才能给出结果。
如果您发布了表格和查询,我们可以帮助您找出这些索引应该是什么。
关于MySQL解释: how to calculate total examined rows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44283741/