EXPLAIN and COUNT returning two different values(EXPLAIN 和 COUNT 返回两个不同的值)
问题描述
我在做:
explain select * from calibration;
它说 52133456345632 行
it says 52133456345632 rows
当我这样做时:
select count(*) from calibration;
我收到了 52134563456961
i am getting 52134563456961
有人能解释一下这里发生了什么吗?
can someone explain whats going on here?
推荐答案
表统计信息(由 EXPLAIN 使用)基于系统缓存的值,可能不准确.
Table statistics (used by EXPLAIN) are based on system-cached values that may not be accurate.
http://dev.mysql.com/doc/refman/5.1/en/using-explain.html 说:
对于 InnoDB 表,这个数字是一个估计值,可能并不总是准确的.
For InnoDB tables, this number is an estimate, and may not always be exact.
因此,'count()' 版本的查询将是准确的,因为它确实会计算"现有行.解释"版本不一定计算您的行数,但可能会使用估计/缓存.解释并不打算在代码或生产中实际使用 - 它只是帮助分析查询的工具.
So the 'count()' version of the query will be accurate, as it will really 'count' existing rows. The 'explain' version does not necessarily count your rows, but might use an estimation/cache. Explain is not intended to be actually used in code or production - it is just a tool to help analysing your queries.
这篇关于EXPLAIN 和 COUNT 返回两个不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:EXPLAIN 和 COUNT 返回两个不同的值


基础教程推荐
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01