MySQL解释: how to calculate total examined rows?

标签 mysql

我在下面有一个解释结果,问题是如何计算检查的总行数?请解释一下这个细节~(先问问题~如有错误,请指正,我将不胜感激)

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/

相关文章:

php - 基于另一个表的动态表插入记录mysql

php - 数据库中的下拉菜单没有结果

php - 在mysql中使用pdo获取多个插入的第一个插入ID

php - Laravel whereHas to realted model,whereHas to that related modal not working

asp.net - 如何在 ASP.NET 中查询 MySQL?

mysql - 在 mysql 中处理大数据的最佳方法

php - mysql 在数据库中调整日期时间值,而不是在搜索返回中

php - Android通过PHP向MySQL数据库插入数据

mysql - Opencart 导入愿望 list 数据

php - 将表单数据插入 MySQL?