EXPLAIN and COUNT returning two different values

試著忘記壹切 提交于 2019-12-20 02:14:03

问题


i am doing:

explain select * from calibration;

it says 52133456345632 rows

when i do:

select count(*) from calibration;

i am getting 52134563456961

can someone explain whats going on here?


回答1:


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.



来源:https://stackoverflow.com/questions/2961745/explain-and-count-returning-two-different-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!