From f77bbd3323f4b0bd6e50ed3016e4cecbdbb7c929 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Mon, 8 Nov 2021 18:27:24 +0000 Subject: [PATCH] upgrade-postgresql: Switch to vacuumdb --all --analzyze-only --jobs 10. The `analyze_new_cluster.sh` script output by `pg_upgrade` just runs `vacuumdb --all --analyze-in-stages`, which runs three passes over the database, getting better stats each time. Each of these passes is independent; the third pass does not require the first two. `--analyze-in-stages` is only provided to get "something" into the database, on the theory that it could then be started and used. Since we wait for all three passes to complete before starting the database, the first two passes add no value. Additionally, PosttgreSQL 14 and up stop writing the `analyze_new_cluster.sh` script as part of `pg_upgrade`, suggesting the equivalent `vacuumdb --all --analyze-in-stages` call instead. Switch to explicitly call `vacuumdb --all --analyze-only`, since we do not gain any benefit from `--analyze-in-stages`. We also enable parallelism, with `--jobs 10`, in order to analyze up to 10 tables in parallel. This may increase load, but will accelerate the upgrade process. --- scripts/setup/upgrade-postgresql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup/upgrade-postgresql b/scripts/setup/upgrade-postgresql index 61a0f1ae8b..9e66bf018f 100755 --- a/scripts/setup/upgrade-postgresql +++ b/scripts/setup/upgrade-postgresql @@ -48,7 +48,7 @@ SCRIPTS_PATH=$(grep -o "/var/log/postgresql/pg_upgradecluster-$UPGRADE_FROM-$UPG crudini --set /etc/zulip/zulip.conf postgresql version "$UPGRADE_TO" # Update the statistics -[ -n "$SCRIPTS_PATH" ] && su postgres -c "$SCRIPTS_PATH/analyze_new_cluster.sh" +su postgres -c "/usr/lib/postgresql/$UPGRADE_TO/bin/vacuumdb --all --analyze-only --jobs 10" # Start the database up cleanly "$ZULIP_PATH"/scripts/zulip-puppet-apply -f