Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a fast but innacurate InnoDB row count?

The FAQ of PHPMyAdmin has this to say about its approximate row counts for InnoDB:

phpMyAdmin uses a quick method to get the row count, and this method only returns an approximate count in the case of InnoDB tables.

I would like to use this 'quick method' - but everywhere I search seems to have a different answer.

Does anyone know?

like image 506
Grim... Avatar asked May 21 '11 15:05

Grim...


1 Answers

They do this:

SHOW TABLE STATUS LIKE 'foo'; 

This returns a 'Rows' column. With MyISAM it's 100% accurate, InnoDB just guesses. This is why MyISAM is faster than InnoDB when doing a 'SELECT COUNT(*)' query without a where clause.

phpMyAdmin is open-source, so you can just go into the code and see for yourself!

like image 95
Lightness Races in Orbit Avatar answered Sep 24 '22 08:09

Lightness Races in Orbit