PostgreSQL major upgrade: choosing pg_upgrade or logical replication by downtime budget
If your self-hosted PostgreSQL cluster must move major versions before PostgreSQL 14 leaves support on November 12, 2026, the method follows from two things: how many seconds or minutes of write downtime the business will accept, and how far back you need to be able to roll. Downtime tolerance and rollback needs decide the method, not the version numbers. The supported paths in the PostgreSQL upgrading documentation are a logical dump and restore with pg_dumpall, an in-place or copy-based upgrade with pg_upgrade, and logical replication into a new major version. Minor releases are different: they never change the internal storage format, so they only replace executables and require a restart. A major upgrade is never a binary swap, which is why the choice matters.
Dump and restore is the simplest path and the slowest at scale, because downtime grows with data volume. pg_upgrade rewrites the catalog and, depending on its mode, either copies, links or clones the data files, so its downtime is largely the time the old cluster is stopped while the upgrade runs. Its rollback is the weak point: the link mode changes files that the old cluster also uses, so reverting means restoring from backup rather than restarting the old binaries. Logical replication, which the documentation says allows a major upgrade with only several seconds of downtime, keeps the old cluster running as the source until the cutover. Its rollback is the reverse replication path you set up in advance, which you must test. Confirm the exact pg_upgrade mode, its rollback behavior and your measured replication lag against the release notes and a rehearsal in your own environment before committing to a window.
What changes between PostgreSQL 14 and 18 and what you must act on
This table lists the changes between PostgreSQL 14 and 18 that affect a major upgrade, with the impact on your environment and the action your team needs to take. Read each row against your own inventory of applications, drivers, extensions and login methods, since the same change can be trivial for one cluster and blocking for another. The main takeaway is that the upgrade is mostly a question of what your clients and roles still depend on, not only of the copy method you choose.
| Change | Impact | Action needed |
|---|---|---|
| pg_upgrade keeps planner statistics, adds parallel jobs and a --swap option | Planner statistics survive the upgrade, so the new cluster may not need a full analyze before serving queries. Parallel jobs can shorten the copy step on large clusters. | Confirm the statistics behavior in your rehearsal, time the run with parallel jobs on a copy of production data, and decide whether --swap fits your cutover plan. |
| Asynchronous I/O added | Changes how reads are issued, so I/O-heavy workloads may behave differently after the upgrade. | Benchmark your heaviest queries on PostgreSQL 18 before cutover and set the new I/O configuration deliberately rather than inheriting defaults. |
| OAuth 2.0 authentication method added | Gives you a new option for token-based login, but only if your identity provider and drivers support it. | Decide whether any roles will use OAuth 2.0 now. Most sites will keep existing methods and need no change in this area. |
| uuidv7() function added | New function for time-ordered UUIDs. Existing UUID columns and values are not changed by the upgrade. | Review application code and schemas if you plan to adopt it. No action is needed for existing data. |
| Virtual generated columns by default | Generated columns that previously were stored may now be virtual, which changes how their values are kept and read. | Search your schemas for generated columns, confirm which kind each one uses after upgrade, and test any indexes or queries that depend on them. |
| MD5 password authentication deprecated in favor of SCRAM | Roles still hashed with MD5 and clients that only support MD5 may fail to log in or raise warnings after the move. | List roles and client drivers that use MD5, migrate passwords to SCRAM before cutover, and update pg_hba.conf methods to match. |
| Minor releases never change the storage format | Minor updates only replace executables and restart, so they do not affect the data files you copy during a major upgrade. | Keep the source cluster on the latest minor release before the upgrade so your rollback target and your rehearsal match production. |
How pg_upgrade and logical replication differ in downtime and rollback
The core difference between the two methods is how long the application stays offline and what state the old cluster is left in. pg_upgrade works on the data directory itself: it reads the old cluster and writes a new one, so the application must be stopped for the cutover window, and that window grows with the amount of work the chosen mode has to do. Its modes differ in how data reaches the new cluster. Copy mode writes new files, so the old cluster stays intact and can be restarted if the upgrade fails, at the cost of extra disk space and time. Link mode creates hard links to the old data files, which is fast but means the old cluster is no longer safe to start once the new one has run, because both now share the same files. Clone mode uses file-system cloning where the platform supports it, which keeps the old cluster intact with much less copying, and the --swap option introduced in PostgreSQL 18 changes the data directories in place rather than copying them. Confirm with the PostgreSQL upgrading documentation which modes your operating system and file system support before you pick one.
Logical replication takes a different route. The old cluster keeps serving traffic while the new major version is populated and kept in sync through a publication and subscription, and the documentation describes a major upgrade with only several seconds of downtime, because the outage is limited to the final switch of write traffic. The old cluster is not modified, so rollback is possible by reversing the replication direction, provided you set up a subscription back to the old version before cutover and have accepted that writes made on the new cluster must be carried back. Sequences, DDL, large objects and extensions are not replicated automatically, so each needs a separate check. The trade-off is more engineering time for the sync setup and validation, and it becomes the sensible choice when the downtime budget is measured in seconds rather than the length of a maintenance window. Ask your team which budget applies before choosing.
Which method fits your downtime budget and rollback needs
A tolerated maintenance window fits a single primary with a manageable database, a known batch schedule and an application team that can accept a stop. pg_upgrade runs against the stopped old cluster, so downtime is the time the upgrade, its checks and the restart take. Copy mode writes a full second copy of the data files, which uses more disk but leaves the old cluster untouched. Link mode hard-links the files instead, which is faster and needs little extra space, but it changes the old cluster's files, so the old cluster cannot simply be started again.
- Copy mode rollback: Keep the old data directory and binaries until the new cluster passes application tests. If nothing has written to the new cluster, restarting the old version is the rollback.
- Link mode rollback: Once the new cluster starts, reverting means restoring from a verified base backup, so take and test that backup before the window.
- Prerequisites: Run pg_upgrade with the check option against the target version, install matching extension builds for the new version, and resolve password method changes such as the MD5 deprecation.
- Swap mode on PostgreSQL 18: Confirm in the PostgreSQL 18 upgrade documentation how the --swap option treats the old data directory before using it in production.
- Planner statistics: PostgreSQL 18 pg_upgrade retains planner statistics, but confirm with your own test results whether you still want a statistics pass after cutover.
Confirm the window length with a timed rehearsal on a copy of production data, including the stop, the upgrade and the restart.
When the downtime budget is measured in seconds, logical replication is the method to evaluate. PostgreSQL documents that logical replication works between major versions and can complete a major upgrade with only several seconds of downtime. The old primary keeps serving traffic while the new version is loaded and kept in sync. Writes are then stopped, the remaining changes drain, sequence values are aligned and clients are pointed at the new server. Schema changes and sequences need explicit handling during the sync period, because the replication stream does not carry them automatically.
- Rollback path: The old cluster stays intact as the source, so a reverse subscription from the new server back to the old one is the usual way to keep a rollback open. Build and test it before cutover.
- Prerequisites: Confirm that replicated tables have the keys the subscription needs and that every data type in use is covered.
- Sequences and schema changes: Plan how sequence values are synchronized and how DDL is frozen or applied on both sides during the sync period.
- Replication lag: Measure lag under peak write load before scheduling the cutover, and set a go or no-go threshold in advance.
- Connection switching: Use a pooler or a DNS change that can redirect clients quickly, and confirm how open connections drain.
Ask for a rehearsal that measures the write freeze, the sequence step and the reverse path, not only the sync speed.
Extensions, standby servers and cluster managers change both paths. pg_upgrade needs the new version's extension shared objects installed before the upgrade, and standbys must be rebuilt or resynchronized against the upgraded primary, a step the upgrade documentation describes. In a Patroni-managed cluster or any setup with automatic failover, failover must be paused during the work, or a half-upgraded node could be promoted. Logical replication adds its own layer, since publisher and subscriber settings must support the stream and any replicas that depend on them.
- Extension pairing: Confirm each extension has a build for the target version and review the update script that pg_upgrade generates. Some extensions may block the move until they are updated.
- Standby servers: Decide whether replicas are rebuilt from the upgraded primary or upgraded separately, and estimate the resync time at your data size.
- Automatic failover: Pause failover in your cluster manager before the upgrade and resume it only after the new topology has been verified.
- Rollback with replicas: A link-mode upgrade on a primary with standbys complicates reverting, so settle the rollback method before choosing the mode.
- Dependent tooling: Confirm that your pooler, backup tooling and monitoring support the new version before cutover.
Verify the topology diagram, the failover settings and the rollback steps with your actual cluster manager and extension list before the window is booked.
Backups, inventory and a rehearsal environment before any cutover
Four controls must be in place before any major upgrade starts: a restorable fallback, a complete inventory of what the cluster depends on, a rehearsal copy that behaves like production, and an agreed point where the team stops and rolls back. Each one shapes which upgrade method is safe to use and how far back the team can go if the cutover fails.
Verified base backup and PITR path
Take a fresh base backup with pg_basebackup and confirm that archived WAL files cover the whole window from that backup to now. Restore the backup to a separate host and replay WAL to a chosen target time. A backup that has never been restored is not a fallback. Record how long the restore took, because that figure sets your real rollback window.
Continuous archiving docsExtension, role and pg_hba inventory
List every installed extension and its version, every role with its attributes, and every rule in pg_hba.conf. Extensions need matching builds for the target version, so note which ones lack a release for it. Roles and HBA rules define who can connect after the cutover. Keep this list in version control so the post-upgrade check can compare against it line by line.
MD5 role passwords to review
Query the role catalog for password hashes that still use MD5 and list the roles and HBA lines that depend on them. PostgreSQL 18 deprecates MD5 password authentication in favor of SCRAM, so any role left on MD5 becomes a migration item rather than a silent carryover. Confirm with each application owner which driver versions support SCRAM before you schedule the change.
Production-like rehearsal environment
Build a copy of the cluster with the same major version, extensions, configuration, data volume shape and authentication setup as production. Run pg_upgrade --check and the full cutover there, then run the application test suite against the upgraded copy. Time each step, because the rehearsal produces the downtime estimate you will give to the business owner.
Documented rollback decision point
Write down the last moment at which the team can return to the old cluster without losing writes, and who has authority to call the rollback. With pg_upgrade the old cluster is only safe to restart if the upgrade mode did not alter its files. With logical replication, rollback means reversing the replication direction. Agree these conditions in writing before the change window opens.
Decision path from downtime budget to upgrade method
The path starts at the target supported version, then asks how much downtime the cutover window tolerates. A window that can absorb a planned outage points toward pg_upgrade, with the mode chosen by the rollback requirement. A cutover measured in seconds points toward logical replication, which keeps the old cluster available as a fallback. Each branch ends at a rehearsal and rollback checkpoint, and the rollback option that branch leaves should be confirmed before the production date is set.
Branches from downtime budget and rollback needs to an upgrade method.
The upgrade sequence with checks and rollback points
The sequence turns a major upgrade into a set of gated stages, each with a check that must pass and a rollback point that shows what the old cluster still holds. Whichever method you choose, the old cluster stays intact until the new one has proven itself under production traffic.
Inventory the cluster and choose the target version
The database owner and the application leads list every database, extension, role, authentication method, replica, connection pooler and dependent application, then record the current version. They compare that version with the support dates in the PostgreSQL versioning policy and pick a target major version that is still supported for the planned operating window. Done means a signed inventory and a target version recorded in the change request, with each extension confirmed to have a build for the target version. Ask your extension vendors or package maintainers to confirm that build before you commit to a date.
Verify backups and point-in-time recovery
Before any change, the operations team takes a fresh base backup of the old cluster and confirms that archived WAL files are continuous through the restore window. They restore that backup to a separate host and replay to a recent target time to prove recovery works, not only that backup jobs succeed. This is rollback point zero: the old cluster and its archive remain untouched and can rebuild the database if every later step fails. Done means a completed test restore with a recorded recovery time and a checksum or row-count comparison against the source.
Rehearse the upgrade on a copy
The team restores a recent copy of the cluster to a non-production host running the target version, then runs the full method end to end with the same extensions, roles and application test suite. They time each stage, record every warning and manual step, and note which application queries or drivers fail under the new version, including password authentication changes. Done means a written runbook with each command, its expected output and the observed duration, plus a list of defects that are closed or accepted by the application owners.
Run pg_upgrade checks or set up logical publication
On the pg_upgrade path, the operator runs pg_upgrade in check mode against the old cluster and resolves every reported incompatibility before stopping any service. On the logical replication path, the team creates the new target cluster, publishes the tables in scope on the source, creates subscriptions on the target, and confirms that initial table synchronization completes for every table. Done means a clean check report (pg_upgrade) or a subscription in which every table reports a ready state (logical replication), with sequences and schema changes handled in the runbook.
Validate catch-up and data parity
For logical replication, the team monitors replication lag until it stays near zero under normal write load, then compares row counts, checksums and sampled data between source and target while writes continue. For pg_upgrade, the team runs the application test suite against the upgraded copy and confirms the planner statistics and query plans on critical workloads. Done means documented parity results and an agreed lag threshold that the cutover window depends on. Ask the operator to state how the comparison handles tables with ongoing writes.
Cut over and switch application connections
At the agreed window, the team stops or freezes writes on the source, waits for the final changes to replicate, and points applications at the new cluster through the connection pooler or DNS change that your environment uses. The old cluster is kept running but not accepting writes, which is the rollback point for this stage: reversing the connection switch returns service to the source with no data loss if no new writes have been accepted by the target. Done means applications report successful connections and the first business transactions complete on the new version.
Check statistics, extensions and performance
After the switch, the team confirms that extensions load and report their expected versions, that authentication succeeds for every role and client type, and that the autovacuum and ANALYZE activity is healthy. They compare key query latencies with the pre-upgrade baseline and rerun ANALYZE where statistics were not carried over by the method used. Done means a sign-off checklist covering extensions, authentication, monitoring and performance, and a list of any open issues with owners.
Retire the old cluster after the rollback window
The old cluster stays in place, stopped or read-only, for a rollback window that the change owner sets in advance and records in the change record. Once that window closes without a rollback decision, the team takes a final backup of the old cluster for retention, removes its replication slots and publications, and decommissions the hardware or containers. Done means a closed change record, the retained final backup verified by restore, and the old cluster removed from monitoring and backup schedules.
What makes a PostgreSQL major upgrade take longer
This table lists the factors that stretch a PostgreSQL major upgrade schedule and the controls that shorten each one. Read it before choosing between pg_upgrade and logical replication, because several drivers apply to both methods while others favor one path. Most delays come from preparation work on extensions, replicas and application drivers rather than from the upgrade command itself.
| Driver | Why it matters | How to reduce it |
|---|---|---|
| Extensions needing matching builds in the new cluster | pg_upgrade needs the extension shared objects for the target version installed before the upgrade runs, and a missing build blocks the check step. | Inventory every installed extension, confirm a build exists for the target major version, and install it on a rehearsal host before the window. |
| Number of replicas and standby rebuilds | Each standby must be upgraded or rebuilt to match the new primary, and a large replica count multiplies the rebuild or resync work. | Ask whether replicas are rebuilt from the new primary or upgraded in place, and script the steps so each replica follows the same runbook. |
| Database size and link versus copy choice | Copy mode writes a full new data directory and grows with database size, while link mode avoids the copy but makes the old cluster unusable once started. | Measure data directory size and free disk space early, and decide link or copy based on the rollback approach you need. |
| Logical replication limits on schema changes and sequences | Logical replication does not carry schema changes or sequence values automatically, so DDL and sequence drift can break the cutover. | Freeze or tightly control DDL during sync, copy sequence values at cutover, and verify row counts and checksums on each table before switching. |
| Custom authentication and MD5 to SCRAM changes | Custom pg_hba.conf rules, LDAP or certificate setups and MD5 password hashes can fail to authenticate on the new cluster and force late fixes. | Review pg_hba.conf and role password types in advance, plan the SCRAM reset with password_encryption, and test each login path in the rehearsal. |
| Connection pooler configuration such as PgBouncer | Pooler targets, auth settings and pool modes must point at the new cluster and match its authentication, or clients connect to the wrong server or fail. | Prepare a pooler configuration for the new cluster, test it against the target version, and document the switch and rollback steps. |
| Application driver compatibility | Older drivers may not support SCRAM authentication or behaviors that changed in the target version, which surfaces only under real traffic. | Confirm driver versions with each application owner, test them against the target version, and include them in the cutover checklist. |
Questions teams ask before upgrading PostgreSQL
How much does a PostgreSQL major upgrade cost and what drives the price?
The cost is mostly the time of people who plan, rehearse, execute and verify the upgrade, plus any environment work needed to run it safely. Your own team pays its engineers' time, and an external partner charges against a written scope. The main drivers are the number of clusters and replicas, the number of extensions and client applications that must be retested, how many staging rehearsals you want, whether you need a second environment for parallel running, and how much downtime you can accept. One-time work covers assessment, rehearsal and cutover. Recurring costs appear only if you buy ongoing support or retainers. Ask any quote to itemize these components so you can compare it with an internal estimate.
How long does a PostgreSQL major upgrade take?
The timeline depends on the scope you agree before work starts, not on a fixed duration. The biggest factors are the number of databases and extensions, the size of the data that must be converted or copied, how many replicas need rebuilding, and how many application teams must sign off on testing. The downtime window is a separate question. Logical replication is documented as allowing a major upgrade with only several seconds of downtime, while pg_upgrade stops the old cluster for the duration of the conversion, so its window grows with the chosen mode and data layout. Confirm the expected window by rehearsing on a copy of production in your own environment.
What does the work need from our team?
Expect to provide named owners for the database, the applications that connect to it, and the change approval process. Your team needs to supply access to the current cluster, configuration files, backup records, a staging environment that resembles production, and a list of extensions and client drivers in use. Application owners must run their test suites against the new version. Your security team should review authentication changes, especially if you still use MD5 password hashes, because PostgreSQL 18 deprecated MD5 in favor of SCRAM. Agree these responsibilities in writing so that testing and sign-off are not left to assumption.
Can our own team do a PostgreSQL major upgrade without a partner?
Yes, many teams do, provided they have engineers who have run PostgreSQL in production and a tested rollback plan. The official upgrade documentation describes pg_dumpall and restore, pg_upgrade, and logical replication, so the method is documented. The difficult parts are usually not the commands but the surrounding work: checking extension compatibility, rehearsing the cutover, reconfiguring replicas and failover tooling, updating connection poolers such as PgBouncer, and proving that backups and point-in-time recovery still work on the new version. Decide honestly whether your team has time and experience for these steps. A partner can take over any part of that list under a fixed scope.
Which method should we choose if downtime must be measured in seconds?
Logical replication is the method the PostgreSQL documentation associates with several seconds of downtime, because it copies changes from the old server to a new one running a different major version and lets you switch applications over once they are in sync. Its trade-offs are more setup, the need to handle schema changes and sequences carefully, and a requirement to confirm that the objects you need are replicated. pg_upgrade is simpler and well documented, but it requires the old cluster to be stopped during conversion. Choose logical replication when the downtime budget is strict and your team can test the cutover thoroughly. Confirm the exact behavior for your schema in a rehearsal.
What does rollback look like after cutover?
Rollback depends on the method you used and what happened after the switch. With pg_upgrade, the documented approach keeps the old cluster available only if you avoided changes that would prevent starting it again, so you must decide in advance how long that fallback remains possible. With logical replication, you can often keep the old server as a subscriber target so that writes made on the new server can be replayed back, but this requires that you planned the reverse path and tested it. In both cases, define the point of no return, the data you would lose if you reverted, and who has authority to trigger the rollback. Backups taken before cutover are your last resort and should be restore-tested first.
Does the upgrade change our security settings or compliance evidence?
It can. PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM, so any role that still stores MD5 hashes or any client that authenticates with MD5 needs a planned change before the upgrade or during it. Upgrading also changes the version you must document for audits, your patch baseline and your backup and restore evidence. Record authentication settings in pg_hba.conf, the role inventory and TLS configuration before and after the upgrade, and keep the outputs of your restore tests. DeployOpen prepares systems, controls and evidence for compliance assessments, but independent auditors issue the actual audit results.
How DeployOpen scopes and delivers a PostgreSQL major upgrade
DeployOpen plans, builds, tests and hands over PostgreSQL major upgrades inside infrastructure you control, with the method chosen from your downtime budget and rollback requirements. Each engagement is fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
How we scope
- Inventory every cluster, database, extension and role that the upgrade touches before choosing pg_upgrade or logical replication.
- Record the downtime budget, the rollback window and the acceptable data loss so the method choice is written down.
- Agree in writing which clusters, replicas, applications and pooler configurations are in scope, and which are excluded.
How we build
- Rehearse the chosen method on a copy of production data in a non-production environment inside your infrastructure.
- Run pg_upgrade --check and review extension, collation and authentication findings before any production cutover.
- Test the logical replication path for replication lag, sequence handling and application connection changes if that method is chosen.
How we hand over
- Deliver a runbook with the exact cutover steps, timings observed during rehearsal, and the rollback procedure for each stage.
- Document which old-cluster data remains available for rollback, how long it is kept, and who approves its removal.
- Hand over verification queries and post-upgrade checks so your own team can confirm the cluster is healthy.
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after the cutover if your team wants continued help.
- Plan follow-on work such as the next minor release cycle, extension updates and planner statistics review in the retainer scope.
- Ask for the support boundaries, response arrangements and what is billed separately as part of the written quote.

