Skip to content

A small list of things to do before you migrate to Postgres 17.

Six checks to run before a major-version upgrade, while rolling back is still cheap.

A major-version Postgres upgrade is usually uneventful. When one goes wrong, the cause is often visible before cutover if you know where to look. This is a short list of places to look before touching a production cluster.

Capture the plans you depend on

The planner changes between major versions. A query that used an index yesterday can choose a sequential scan tomorrow. Before the upgrade, save the plans for your slowest and most important queries so you have something to diff against.

snapshot.sql
-- Run on the old version with a representative value, and save the output.
-- A bare $1 is rejected by EXPLAIN unless the statement is PREPAREd first.
EXPLAIN (FORMAT JSON)
SELECT id, total
FROM orders
WHERE customer_id = 42
ORDER BY created_at DESC
LIMIT 50;

After the upgrade (and after statistics are rebuilt, see below), run the same statements and compare. A plan that flipped from Index Scan to Seq Scan is exactly the kind of regression this catches, and it is far cheaper to catch here than in production.

The rest of the list

  • Rebuild planner statistics immediately after the upgrade. pg_upgrade does not carry optimizer statistics over to 17, and neither does a dump and restore, so tables start with none; run vacuumdb --all --analyze-in-stages before you trust any plan.
  • Check that every extension you use has a 17-compatible build installed on the new server before you start, not during; plan to run ALTER EXTENSION ... UPDATE afterwards.
  • If anything consumes logical replication slots (a CDC pipeline, a logical subscriber), make sure it has caught up before shutdown and plan to recreate the slots. pg_upgrade only preserves logical slots when the old cluster is already on 17 or later.
  • Diff pg_settings between old and new; defaults move between major versions, and a setting you never touched may have changed underneath you.
  • Keep the old cluster intact until you are confident. With pg_upgrade --link, the old cluster cannot safely be started once the new one has run, so if you want that rollback path, use copy mode or take a verified backup first.

None of this is clever. All of it is the difference between a boring Tuesday and a long one.