mysql table_rows,MySQL的行数count(*)与information_schema中的table.table_rows不一致

i came across a strange phenomenon, and i hope, that someone can explain this to me:

i have a some "static" tables (they change once per day).

mysql> select 'appObjectGroups' as tbl, count(*) as num from appObjectGroups

union select 'appObjectDependencies' as tbl, count(*) as num from appObjectDependencies

union select 'appObjectUrls' as tbl, count(*) as num from appObjectUrls

union select 'appObjectValues' as tbl, count(*) as num from appObjectValues

union select 'appObjects;' as tbl, count(*) as num from appObjects;

+-------------------------+------+

| tbl | num |

+-------------------------+------+

| appObjectGroups | 1149 |

| appObjectDependencies | 6885 |

| appObjectUrls | 1162 |

| appObjectValues | 3795 |

| appObjects; | 5409 |

+-------------------------+------+

5 rows in set (0.00 sec)

mysql> select table_name as tbl, table_rows as num from information_schema.tables where table_schema='mySchema' and table_name like 'app%';

+-------------------------+------+

| tbl | num |

+-------------------------+------+

| appObjectGroups | 1141 |

| appObjectDependencies | 6153 |

| appObjectUrls | 1141 |

| appObjectValues | 3584 |

| appObjects | 6061 |

+-------------------------+------+

5 rows in set (0.01 sec)

so how come that table_rows report something different than count(*)?

and more important to me: which one is correct? :-)

解决方案

Quoting from documentation:

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值