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 返回两个不同的值
基础教程推荐
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 在多列上分布任意行 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
