Skip to content
HoginHogin
Go back

PostgreSQL 19: what's actually production-ready — REPACK, async I/O and a no-panic upgrade plan

11 мин чтения

PostgreSQL 19 shipped on November 19, 2026 — RC1 was announced October 15, features are frozen, release notes are out. This is a rare release that changes not “another couple percent in the planner” but operational routine: online repacking of bloated tables, async I/O, and parallel autovacuum. Below — a no-marketing breakdown: what to take to production right away, what to hold until 19.1, and how to build an upgrade that doesn’t turn into a nightly drama series.

Table of contents

Open Table of contents

Three themes that matter to an ops engineer

Three things in nineteen hit operations pain dead-on:

There’s also a layer of breaking changes — few, but with a couple of surprises (JIT is now off by default). Let’s go through it all.

REPACK: the end of the VACUUM FULL era

An old problem, familiar to anyone who has run a large OLTP database: UPDATE and DELETE leave dead rows, VACUUM marks the space reusable, but never shrinks the file. A year of heavy churn later, a table holding 40 GB of data lives in a 200 GB file — bloat. Indexes suffer the same way.

The built-in ways to compact it were two, both bad: VACUUM FULL and CLUSTER take an ACCESS EXCLUSIVE lock — for the duration of the rewrite the table is unavailable to absolutely everyone. On a terabyte table that’s hours. Hence the industry crutch pg_repack: online rewrite via a temporary copy, but an external tool you have to install, upgrade, and clean up replication slots after.

VACUUM FULL locks the whole table, REPACK (CONCURRENTLY) works online

In 19 this is solved in the core: the new REPACK command replaces both VACUUM FULL and CLUSTER (the old ones remain for compatibility — there’s no reason to keep using them):

REPACK TABLE events;                -- fast, but ACCESS EXCLUSIVE, like VACUUM FULL
REPACK (CONCURRENTLY) TABLE events; -- online: reads and writes keep going

What matters about CONCURRENTLY:

The practical effect: repacking bloated tables stops being a “Saturday night with sign-off” event and becomes a routine background operation.

Async I/O: from experiment to normal

For honesty: asynchronous I/O didn’t appear in 19 — io_method = worker | io_uring arrived in PostgreSQL 18. There it felt like “enable it and see if you’re lucky”. In 19 the machinery was finished:

sync I/O issues requests one at a time, io_uring queues them while the disk works in parallel

What to enable: on Linux 5.10+ try io_method = io_uring; worker is the safe fallback. One Kubernetes caveat: container runtime seccomp profiles have historically blocked io_uring syscalls — if the database in a pod refuses to start with io_uring, check the profile first. Measure before and after switching: your heaviest seq scan under EXPLAIN (ANALYZE, BUFFERS, IO) plus pg_stat_io.

Optimizer and autovacuum: quiet but useful

No loud planner headlines in this release, but several changes land in typical queries.

NOT IN becomes an ANTI JOIN. A classic antipattern that used to execute as a nested subplan:

SELECT count(*) FROM orders
WHERE customer_id NOT IN (
    SELECT customer_id FROM blocked_customers
    WHERE removed_at IS NULL
);

Every NOT IN used to run as a SubPlan — row by row, degrading badly at scale. Now, when NULLs don’t interfere (as here — removed_at IS NULL guarantees no NULLs from the subquery), the planner rewrites it into an anti join executed with a hash. More LEFT JOINs get rewritten into anti joins too, Memoize now works for anti joins with unique inner sides, and some aggregation is pushed below the join — fewer rows enter the JOIN in the first place.

For advanced users — the pg_plan_advice and pg_stash_advice extensions: planner decision control keyed by query id, the answer to the eternal “the plan keeps flip-flopping”.

Autovacuum:

PostgreSQL 18 vs 19

PostgreSQL 18PostgreSQL 19
Bloat compactionVACUUM FULL / CLUSTER with a lock, or external pg_repackREPACK (CONCURRENTLY) online, built in
Async I/Oio_method with fixed io_workers, no observabilityauto-scaling workers, better read-ahead, EXPLAIN (ANALYZE, IO)
Autovacuumindexes cleaned sequentially, order by ageparallel workers + priority scoring (pg_stat_autovacuum_scores)
NOT IN (SELECT …)SubPlan, degrades at scalerewritten as an ANTI JOIN
Logical replicationneeds wal_level = logical + restartenables at wal_level = replica without restart
Sequences in logical replicationmoved by hand after cutoverpublished and synchronized (REFRESH SEQUENCES)
JITon by defaultoff by default
TOAST compressionpglzlz4 by default

What you need to migrate

Breaking changes first

There are few, but check before, not after:

pg_upgrade --link — minutes even on hundreds of gigabytes: files aren’t copied but hard-linked between the old and new PGDATA. The price: once the new cluster starts, the old one is dead (data is shared), there is no way back without a backup, and downtime equals upgrade time plus application checks. Fits when a 10–30 minute window is acceptable.

Logical replication — near-zero downtime: stand up 19 next to it, subscribe, catch up, switch the application. The historical pains are manual DDL and especially sequences (moved by scripts, then duplicate-key errors on the new cluster). In 19 both pains shrink: sequences are published and synchronized by Postgres itself (ALL SEQUENCES / REFRESH SEQUENCES), and enabling logical replication only needs wal_level = replica — no more restart with logical just to start a migration. DDL is still manual. A bonus for standby setups: the new WAIT command gives read-your-writes after a switchover — the application waits for a specific LSN instead of “it’ll catch up eventually”.

The rehearsal on a clone is mandatory, it’s part of the plan. Clone production (a pgBackRest restore — covered here) and run:

# 1. dry run: surfaces every reason it would fail, in advance
/usr/lib/postgresql/19/bin/pg_upgrade \
  --old-bindir=/usr/lib/postgresql/18/bin \
  --new-bindir=/usr/lib/postgresql/19/bin \
  --old-datadir=/var/lib/postgresql/18/main \
  --new-datadir=/var/lib/postgresql/19/main \
  --link --check

# 2. the real run, timed — this is your downtime window
time /usr/lib/postgresql/19/bin/pg_upgrade \
  --old-bindir=/usr/lib/postgresql/18/bin \
  --new-bindir=/usr/lib/postgresql/19/bin \
  --old-datadir=/var/lib/postgresql/18/main \
  --new-datadir=/var/lib/postgresql/19/main \
  --link --jobs 4

After the upgrade — ANALYZE (pg_upgrade has --analyze-in-stages), application smoke tests, and only then the production switch.

A config for 19

A minimal postgresql.conf to start from:

# async I/O: io_uring on kernel 5.10+, otherwise worker
io_method = io_uring
io_max_workers = 8          # auto-scaling ceiling; minimum and timeouts — defaults

# autovacuum: parallel index cleanup
autovacuum_max_parallel_workers = 2
log_autoanalyze_min_duration = 10s   # long ANALYZE runs — separate log

# if analytics got slower after the upgrade — bring JIT back
# jit = on

Then watch: pg_stat_io, EXPLAIN (ANALYZE, IO) on heavy queries, pg_stat_autovacuum_scores on hot tables.

In Kubernetes: CloudNativePG

If the database runs under CloudNativePG, since 1.24 the operator handles major upgrades itself: you change the image version in spec.imageName — it spawns a temporary instance, runs pg_upgrade, and rolls the cluster. Check before:

How to verify it works

Three quick checks after the upgrade:

psql -c "SHOW io_method;"                 # io_uring (or worker, if that's the call)
-- async I/O in action on a heavy seq scan
EXPLAIN (ANALYZE, BUFFERS, IO)
SELECT count(*) FROM events WHERE created_at > now() - interval '7 days';

-- repack progress in real time
SELECT * FROM pg_stat_progress_repack;

-- what autovacuum cleans next
SELECT * FROM pg_stat_autovacuum_scores ORDER BY score DESC LIMIT 10;

The difference from sync in EXPLAIN is obvious on a cold cache. And run REPACK (CONCURRENTLY) on a test bloated table during the rehearsal: you’ll see the phases in pg_stat_progress_repack and the slot in pg_replication_slots that must disappear when it finishes.

Bottom line

Don’t upgrade production on GA day — this is 19.0, and the first minor (19.1) traditionally lands a quarter later: by February 2027 the freshest bugs will be collected. But don’t park it in “someday” either: REPACK (CONCURRENTLY) closes Postgres’ oldest operational pain, async I/O finally has observability, and sequence replication plus restart-free enablement remove the two main arguments against a zero-downtime migration. The plan: now — a rehearsal on a clone and a pass over breaking changes; at 19.1 — production via pg_upgrade --link with a short window or via logical replication without one. It’s a fair trade: a few evenings of preparation in exchange for the end of nightly VACUUM FULL drama.


Share this post:

Next Post
AWS from scratch, part 5: putting it all together — a secure baseline EKS + RDS Postgres setup