PostgreSQL Major Version Upgrade Planner
Choosing how to run a PostgreSQL major version upgrade comes down to three numbers: how much data you have, how much downtime you can afford, and how much spare disk is on the box. Enter those and this planner recommends pg_upgrade in link or copy mode, a dump and restore, or a logical replication cutover, with a downtime estimate for each so you can see why. It then generates the step-by-step commands for the method you picked, the preflight SQL to run on the old cluster while it is still serving traffic, and the list of breaking changes you cross on the way from your current version to your target. Everything is computed in your browser — no server details are sent anywhere.
Do more than postgresql major version upgrade planner — meet Chat2DB
Chat2DB is an AI-powered SQL client for Windows, macOS and Linux. Write SQL in natural language, format and optimize queries automatically, and manage MySQL, PostgreSQL, Oracle and 20+ other databases in one workspace.
How to use
- Set your current and target major versions, the platform, your data size and free disk space, and how long an outage you can accept.
- Leave the method on 'Recommend one for me' to see the comparison, or force a specific method to see its plan and downtime estimate.
- Work through the preflight SQL on the old cluster first, read the breaking-changes list, then rehearse the generated command plan on a restored copy before the real window.
Frequently asked questions
Is pg_upgrade --link safe to use in production?
It is safe in the sense that it is a supported, widely used mode, and it is the only way to upgrade a multi-terabyte cluster in minutes: instead of copying the data files it creates hard links to them, so the runtime barely depends on database size. The catch is the rollback. Because both clusters point at the same files on disk, once the new cluster has started and written anything, the old cluster is no longer consistent — you cannot simply restart the old binaries. Your rollback becomes a restore from backup, so the rule is: never run --link without a verified backup and a tested restore, and never delete the old cluster until the new one has served real traffic. If you have the disk space and the window, plain copy mode keeps the old cluster bootable, which is worth a lot on a stressful night.
How do I upgrade PostgreSQL with almost no downtime?
Use logical replication. Build the new cluster on the target version, copy the schema across with pg_dump --schema-only, create a publication on the old cluster and a subscription on the new one, and let the initial copy plus ongoing replication run for as long as it takes — hours or days, with the application still live on the old cluster. The downtime is then only the cutover: stop writes, wait for the replication lag to hit zero, advance the sequences (logical replication does not replicate them), and repoint the application. That is typically a couple of minutes. The costs are that the old cluster needs wal_level = logical, tables without a primary key need REPLICA IDENTITY FULL, and DDL is not replicated, so the schema has to stay frozen during the migration window.
Do I have to run ANALYZE after a PostgreSQL major upgrade?
Yes, for any upgrade to a version before 18. pg_upgrade migrates the data and the catalogue but not the planner statistics, so the moment the new cluster starts, every table looks statistically empty and the planner picks bad plans — this is the single most common cause of a 'the upgrade broke performance' incident. Run vacuumdb --all --analyze-in-stages immediately after starting the new cluster; the staged mode produces rough statistics fast, then refines them, so the site recovers in the first stage rather than at the end. PostgreSQL 18's pg_upgrade carries most statistics over, which removes the cliff, but running analyze afterwards is still cheap insurance.
