I have a largish but narrow InnoDB table with ~9m records. Doing count(*) or count(id) on the table is extremely slow (6+ seconds):
count(*)
count(id)
select max(id) - min(id) from xxx_table where ....
select max(id) - min(id) from xxx_table where
This will use "Select tables optimized away", and is very fast!!!
Note max(id) - min(id) is actually bigger than count(1).
max(id) - min(id)
count(1)