From d5f1b6a75ba3f55a78959c957c3fd25d9569057c Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Wed, 30 Apr 2025 14:12:59 -0500 Subject: Further adjust guidance for running vacuumdb after pg_upgrade. Since pg_upgrade does not transfer the cumulative statistics used to trigger autovacuum and autoanalyze, the server may take much longer than expected to process them post-upgrade. Currently, we recommend analyzing only relations for which optimizer statistics were not transferred by using the --analyze-in-stages and --missing-stats-only options. This commit appends another recommendation to analyze all relations to update the relevant cumulative statistics by using the --analyze-only option. This is similar to the recommendation for pg_stat_reset(). Reported-by: Christoph Berg Reviewed-by: Christoph Berg Discussion: https://postgr.es/m/aAfxfKC82B9NvJDj%40msg.df7cb.de --- doc/src/sgml/ref/pgupgrade.sgml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml index df13365b287..648c6e2967c 100644 --- a/doc/src/sgml/ref/pgupgrade.sgml +++ b/doc/src/sgml/ref/pgupgrade.sgml @@ -833,17 +833,19 @@ psql --username=postgres --file=script.sql postgres Because not all statistics are not transferred by - pg_upgrade, you will be instructed to run a command to + pg_upgrade, you will be instructed to run commands to regenerate that information at the end of the upgrade. You might need to set connection parameters to match your new cluster. - Using vacuumdb --all --analyze-only --missing-stats-only - can efficiently generate such statistics. Alternatively, + First, use vacuumdb --all --analyze-in-stages --missing-stats-only - can be used to generate minimal statistics quickly. For either command, - the use of can speed it up. + to quickly generate minimal optimizer statistics for relations without + any. Then, use vacuumdb --all --analyze-only to ensure + all relations have updated cumulative statistics for triggering vacuum and + analyze. For both commands, the use of can speed + it up. If vacuum_cost_delay is set to a non-zero value, this can be overridden to speed up statistics generation using PGOPTIONS, e.g., PGOPTIONS='-c -- cgit v1.2.3