4 ms·
There is no fiasco in count(*), it is THE general behavior of any MVCC database. Try the same with MySQL InnoDB, you get the same result (or worse). MySQL MyIS
by reactor 14y ago
There is no fiasco in count(*), it is THE general behavior of any MVCC database. Try the same with MySQL InnoDB, you get the same result (or worse).
MySQL MyISAM DB gets the result fast because it is non-trasactional.
To get approximate count very quickly on Pg, you can use
-- select reltuples from pg_class where relname='<table_name>';
- jeltz 14y agoIndeed, in the benchmarks I have seen PostgreSQL is faster then InnoDB at running count(*) over entire tables but slower when a indexable WHERE clause was added due to the lack of index only scans in PostgreSQL. This may change in 9.2.