开发者

EXPLAIN and COUNT returning two different values

开发者 https://www.devze.com 2023-01-01 19:58 出处:网络
i am doing: explain select * from calibration; it says 52133456345632 rows when i do: select count(*) from calibration;

i am doing:

explain select * from calibration;

it says 52133456345632 rows

when i do:

select count(*) from calibration;

i am开发者_StackOverflow中文版 getting 52134563456961

can someone explain whats going on here?


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 says:

For InnoDB tables, this number is an estimate, and may not always be exact.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号