EXPLAIN和COUNT返回两个不同的值 [英] EXPLAIN and COUNT returning two different values

查看:578
本文介绍了EXPLAIN和COUNT返回两个不同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做:

explain select * from calibration;

它说52133456345632行

it says 52133456345632 rows

do:

select count(*) from calibration;

我得到52134563456961

i am getting 52134563456961

推荐答案

表统计信息(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()'版本的查询将是准确的,因为它将真正计数现有行。 explain版本不一定计数你的行,但可能使用估计/缓存。说明不是要在代码或生产中实际使用 - 它只是一个帮助分析查询的工具。

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返回两个不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆