我在做:
explain select * from calibration;
它说 52133456345632 行
当我这样做时:
select count(*) from calibration;
我得到 52134563456961
谁能解释一下这是怎么回事?
最佳答案
表统计信息(由 EXPLAIN 使用)基于可能不准确的系统缓存值。
http://dev.mysql.com/doc/refman/5.1/en/using-explain.html说:
For InnoDB tables, this number is an estimate, and may not always be exact.
因此查询的“count()”版本将是准确的,因为它会真正“计算”现有行。 “解释”版本不一定计算您的行数,但可能会使用估计/缓存。 Explain 并非旨在实际用于代码或生产中 - 它只是一种帮助分析查询的工具。
关于sql - EXPLAIN 和 COUNT 返回两个不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2961745/