Skip to content

Commit d5f1b6a

Browse files
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 <[email protected]> Reviewed-by: Christoph Berg <[email protected]> Discussion: https://postgr.es/m/aAfxfKC82B9NvJDj%40msg.df7cb.de
1 parent f60420c commit d5f1b6a

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

doc/src/sgml/ref/pgupgrade.sgml

+7-5
Original file line numberDiff line numberDiff line change
@@ -833,17 +833,19 @@ psql --username=postgres --file=script.sql postgres
833833

834834
<para>
835835
Because not all statistics are not transferred by
836-
<command>pg_upgrade</command>, you will be instructed to run a command to
836+
<command>pg_upgrade</command>, you will be instructed to run commands to
837837
regenerate that information at the end of the upgrade. You might need to
838838
set connection parameters to match your new cluster.
839839
</para>
840840

841841
<para>
842-
Using <command>vacuumdb --all --analyze-only --missing-stats-only</command>
843-
can efficiently generate such statistics. Alternatively,
842+
First, use
844843
<command>vacuumdb --all --analyze-in-stages --missing-stats-only</command>
845-
can be used to generate minimal statistics quickly. For either command,
846-
the use of <option>--jobs</option> can speed it up.
844+
to quickly generate minimal optimizer statistics for relations without
845+
any. Then, use <command>vacuumdb --all --analyze-only</command> to ensure
846+
all relations have updated cumulative statistics for triggering vacuum and
847+
analyze. For both commands, the use of <option>--jobs</option> can speed
848+
it up.
847849
If <varname>vacuum_cost_delay</varname> is set to a non-zero
848850
value, this can be overridden to speed up statistics generation
849851
using <envar>PGOPTIONS</envar>, e.g., <literal>PGOPTIONS='-c

src/bin/pg_upgrade/check.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,12 @@ output_completion_banner(char *deletion_script_file_name)
814814
}
815815

816816
pg_log(PG_REPORT,
817-
"Some optimizer statistics may not have been transferred by pg_upgrade.\n"
818-
"Once you start the new server, consider running:\n"
819-
" %s/vacuumdb %s--all --analyze-in-stages --missing-stats-only", new_cluster.bindir, user_specification.data);
817+
"Some statistics are not transferred by pg_upgrade.\n"
818+
"Once you start the new server, consider running these two commands:\n"
819+
" %s/vacuumdb %s--all --analyze-in-stages --missing-stats-only\n"
820+
" %s/vacuumdb %s--all --analyze-only",
821+
new_cluster.bindir, user_specification.data,
822+
new_cluster.bindir, user_specification.data);
820823

821824
if (deletion_script_file_name)
822825
pg_log(PG_REPORT,

0 commit comments

Comments
 (0)