In MyISAM this query:
SELECT COUNT(*) FROM TABLE_NAME
is instantaneous since it is stored in the table metadata, so it almost frees this query and will always have the correct result.
In InnoDB this query will count the rows one by one, which may take some time.
So, if you do not need the exact COUNT(*) value, you can request INFORMATION_SCHEMA .
Quassnoi
source share