暂无图片
mysql innoDB information_schema.tables table_rows值并不准确的值。
我来答
分享
暂无图片 匿名用户
mysql innoDB information_schema.tables table_rows值并不准确的值。
  • 如果想准确查到某个库中所有表行数大于1000万条的表,怎么办呢?


  • TABLE_ROWS

    The number of rows. Some storage engines, such as MyISAM, store the exact count. For other storage engines, such as InnoDB, this value is an approximation, and may vary from the actual value by as much as 40% to 50%. In such cases, use SELECT COUNT(*) to obtain an accurate count.

    TABLE_ROWS is NULL for INFORMATION_SCHEMA tables.

    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.)

我来答
添加附件
收藏
分享
问题补充
3条回答
默认
最新
chengang

1、执行 analyze table tablename
2、select * from mysql.innodb_table_stats 查看n_rows列即可。

暂无图片 评论
暂无图片 有用 6
笑看风云

table_rows每次收集统计信息得到,由于analyze的采样率比较低,所以table_rows是个预估值,而不是精确值,如果采样率设置100%有效率大量的CPU和IO资源,没必要,对于CBO来说,统计信息具有代表性就ok了。

暂无图片 评论
暂无图片 有用 0
张sir

这个表里是记录的统计信息,肯定是不准的,如果需要得到准确的值的话,只能进行count(*).

暂无图片 评论
暂无图片 有用 0
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏