·16 min read
SELECT COUNT(*) is slow on 30M rows: how to make counting fast at scale
Why COUNT(*) degrades on a 30M-row table under MVCC, and the full ladder of fixes — keyset pagination, planner estimates, capped counts, covering indexes, sharded summary counters, rollup tables and OLAP replicas — with the MySQL and PostgreSQL code for each and a table for picking the right one.
Intermediate- Databases
- Performance
- MySQL
- PostgreSQL