4 ms·
As others have pointed out, there is no such "fiasco". However, if you want to simply count the entire table and don't care if the number is exact within the cu
by lobster_johnson 15y ago
As others have pointed out, there is no such "fiasco". However, if you want to simply count the entire table and don't care if the number is exact within the current transaction, you can cheat and do:
select n_live_tup from pg_stat_user_tables
where relname = 'your_table_name'
This will access the internal statistics about how many tuples are in the table. It ignores the transaction's isolation level since it's a global value, and it may be a few milliseconds out of date, but it's otherwise correct.