News for hackers. Stuff that matters.
Re:MySQL 8.0 is now generally available by mfjordvald on Thursday April 19, 2018 @10:52PM (#16881832)
count(*) doesn't do full table scan as it's not tied to specific data. It has special handling logic. The only case where it might have to do a full table scan is if you try to count() on a specific (nullable?) column without an index.
Re:MySQL 8.0 is now generally available by zht on Friday April 20, 2018 @09:35AM (#16884622)
I've always had select count(*) do a full table scan (or at least take considerable time) in innodb... Did something change?
Re:MySQL 8.0 is now generally available by evanelias on Friday April 20, 2018 @10:36AM (#16885090)
Without a WHERE clause, select count(*) still does a full table scan (or full index scan) in InnoDB, and probably always will.

It is optimized in MyISAM via table-level metadata, which is only possible because MyISAM doesn't use MVCC or support transactions.

In InnoDB, you can get an estimated row count from SHOW TABLE STATUS, but the estimate is based on table stats and can be wildly inaccurate.