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 返回两个不同的值


- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- SQL 临时表问题 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01