在使用navicat进行数据库管理的时候,在查看表对象的时候会发现,每次刷新,数据表的记录数不断变化,尤其是大表。
对于100万的数据经常会显示九十几万,当然通过count(*)出来的数据是正确的。
非常疑惑,查了一下资料,原来和存储引擎有关。官方说明:
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.
在myisam这种不支持事务的引擎中,这个值是精确的,在innodb这种支持事务的引擎中,是估算的。 https://dev.mysql.com/doc/refman/5.1/en/show-table-status.html