On Sun, 2023-12-24 at 15:53 +0000, Murthy Nunna wrote:
> I did pg_dump of a ~20TB database followed by pg_restore. I find simple queries like select
> count(*) running slow. I did a select count(*) on all tables before pg_dump which took ~4 hours.
> After pg_restore, same thing took 32 hours.
SELECT count(*) is always slow.
> By the way, there is no change in postgres versions. It is 14.4 before and after pg_restore.
You should compare the execution plans of the queries on the old and the new server.
Besides, if you are running lots of count(*) queries, you are doing something wrong:
https://www.cybertec-postgresql.com/en/pagination-problem-total-result-count/#total-count
Yours,
Laurenz Albe