将 information_schema.TABLES.table_rows 列与从“SELECT count(*) from ”检索到的物理行数进行比较时,数字不匹配。为什么行数不同?
mysql> select TABLE_ROWS from TABLES where TABLE_NAME = 'gbl_session' and TABLE_SCHEMA = 'mydb';
+------------+
| TABLE_ROWS |
+------------+
| 7306 |
+------------+
1 row in set (0.01 sec)
mysql> select count(*) from mydb.gbl_session;
+----------+
| count(*) |
+----------+
| 7800 |
+----------+
1 row in set (0.01 sec)
最佳答案
For InnoDB tables, the row count is only a rough estimate used in SQL optimization. (This is also true if the InnoDB table is partitioned.)
阅读此内容了解更多信息:https://dev.mysql.com/doc/refman/5.1/en/tables-table.html
正如那里的评论所建议的那样,您可以尝试:
TABLE_ROWS (and perhaps some other columns in INFORMATION_SCHEMA.TABLES) may get out of sync with the current table contents, but you can update it by running ANALYZE.
关于mysql - 为什么数据库表 TABLES.table_rows 列与 MySQL 中物理表中的 select count(*) 不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31567817/