EXPLAIN and COUNT return two different values.

I do:

explain select * from calibration; 

he says 52133456345632 lines

when i do:

 select count(*) from calibration; 

I get 52134563456961

can someone explain what is going on here?

+3
sql mysql count sql-execution-plan
Jun 02. '10 at 21:30
source share
1 answer

Table statistics (used by EXPLAIN) are based on system caches, which may be inaccurate.

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 accurate.

This way, the version of the count () query will be accurate, since it really "counts" the existing rows. The 'explain' version does not necessarily take your lines into account, but it can use an estimate / cache. The explanation is not intended for actual use in code or production - it is just a tool to analyze your requests.

+7
Jun 02 '10 at 21:33
source share



All Articles