summaryrefslogtreecommitdiffstats
path: root/pg_upgradecluster.d/analyze
diff options
context:
space:
mode:
Diffstat (limited to 'pg_upgradecluster.d/analyze')
-rwxr-xr-xpg_upgradecluster.d/analyze33
1 files changed, 33 insertions, 0 deletions
diff --git a/pg_upgradecluster.d/analyze b/pg_upgradecluster.d/analyze
new file mode 100755
index 0000000..f410365
--- /dev/null
+++ b/pg_upgradecluster.d/analyze
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Run ANALYZE on all databases in the upgraded cluster
+
+set -eu
+
+oldversion="$1"
+cluster="$2"
+newversion="$3"
+phase="$4"
+
+case $newversion in
+ 9.2|9.3)
+ analyze="--analyze-only"
+ ;;
+ *)
+ analyze="--analyze-in-stages"
+ ;;
+esac
+
+case $newversion in
+ 9.5|9.6|[1-7]*)
+ [ "${PGJOBS:-}" ] && jobs="--jobs=$PGJOBS"
+ ;;
+esac
+
+case $phase in
+ finish)
+ vacuumdb --cluster "$newversion/$cluster" --all $analyze ${jobs:-}
+ ;;
+esac
+
+exit 0