【问题标题】:Why the difference between record count values为什么记录计数值之间存在差异
【发布时间】:2012-09-29 15:33:10
【问题描述】:

实际上我的目的是找出我的数据库中存在的记录数,以便找出我已经执行了像 select sum(table_rows) from information_schema.tables where table_schema='database_name'; 这样的查询。 它给了我一些价值,比如 90658965

之后我需要单个表中存在的记录数,因此我执行了以下查询 select table_rows,table_name from information_schema.tables where table_schema='database_name'; 我得到了像 3781(table_rows) 和 ticket(table_name)

这样的结果

所以为了交叉验证,我执行了如下查询 从工单中选择 count(*); 我得到了类似 3552

的结果

为什么上述两个查询的表数存在差异
tickets 表的存储引擎是 innodb

【问题讨论】:

    标签: mysql


    【解决方案1】:
    SELECT COUNT(*) FROM TABLENAME
    

    本次查询为资源激励操作。

    information_schema.tables 的总回报是正确的

    【讨论】:

      【解决方案2】:

      The INFORMATION_SCHEMA TABLES Table 中所述:

      对于InnoDB 表,行数只是SQL 优化中使用的粗略估计。 (如果InnoDB 表是分区的,也是如此。)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-09-29
        • 2016-03-23
        • 1970-01-01
        • 2023-04-09
        • 1970-01-01
        • 2021-03-18
        • 1970-01-01
        相关资源
        最近更新 更多