pg_upgrade too slow on vacuum phase - Mailing list pgsql-general

From Kouber Saparev
Subject pg_upgrade too slow on vacuum phase
Date
Msg-id CAN4RuQt+4J9zS1p4kwy_2P5nRG3eKJsHA16nLfePvFf6ZVcmZQ@mail.gmail.com
Whole thread Raw
Responses Re: pg_upgrade too slow on vacuum phase  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
I am trying to upgrade PostgreSQL from 9.5 to 12 using pg_upgrade.

/usr/lib/postgresql/12/bin/pg_upgrade \
  --old-datadir=/var/lib/postgresql/9.5/main \
  --new-datadir=/var/lib/postgresql/12/main \
  --old-bindir=/usr/lib/postgresql/9.5/bin \
  --new-bindir=/usr/lib/postgresql/12/bin \
  --old-options '-c config_file=/etc/postgresql/9.5/main/postgresql.conf' \
  --new-options '-c config_file=/etc/postgresql/12/main/postgresql.conf' \
  --link \
  --jobs=16

It takes 47 minutes for the upgrade to finish (for a 28 GB database). It hangs on two particular steps:

Analyzing all rows in the new cluster                       ok
Freezing all rows in the new cluster                        ok

Which basically runs:

vacuumdb --all --analyze
vacuumdb --all --freeze

This is where all these 47 minutes are spent, yet I do not understand neither why, nor how I can improve this part. Can I skip it somehow and launch the vacuum manually afterwards?

Per postgresql.conf, I gave:

work_mem = 128MB
maintenance_work_mem = 8GB
max_parallel_maintenance_workers = 16
max_parallel_workers = 16

The server has 44 GB available memory, and 24 cores.

Do you have any ideas how to speed-up the entire process?

--
Kouber Saparev

pgsql-general by date:

Previous
From: Mariya Rampurawala
Date:
Subject: Re: [EXTERNAL] Re: PostgreSQL-12 replication failover, pg_rewindfails
Next
From: Matthias Apitz
Date:
Subject: ESQL/C: a ROLLBACK rolls back a COMMITED transaction