PostgreSQL 19: online repacking and new query plan dials
PostgreSQL 19 brings online REPACK and planner controls. Less downtime, more predictable plans. My take: run compatibility and load tests before upgrading.
PostgreSQL 19 lands with REPACK and new query planning controls. The pitch: lower maintenance disruption and more levers to shape plans without touching app code. If you run serious OLTP/OLAP, this might save a few weekends.
What happened
The headliner is REPACK, which reclaims table space and can reorder data to match an index. With CONCURRENTLY it doesn’t block reads or writes, a drop-in for many VACUUM FULL and CLUSTER jobs.
New extensions pg_plan_advice and pg_stash_advice let you influence plan selection and apply stored advice by query identifier, no app changes needed. Also: parallel index vacuuming, tweaks to autovacuum prioritization, and extra monitoring views.
EXPLAIN ANALYZE and logging now report async I/O and WAL generated for full-page images. Planner got better anti-joins for eligible NOT IN and eager aggregation before joins. Tests showed bulk inserts nearly 2x faster after foreign key check changes.
Replication and dev: logical replication supports sequence values, and the server auto-raises effective WAL level to logical when the first logical slot is created. WAIT FOR LSN lets apps wait until a standby replays a WAL position, enabling read-your-writes. For developers: INSERT ... ON CONFLICT DO SELECT for get-or-create, JSON output from COPY, more SQL/JSON string methods, and IGNORE NULLS for window functions.
Security and compatibility: server-side TLS SNI (different certs per hostname), a warning after successful MD5 auth (MD5 was deprecated in 18 and is slated for removal; SCRAM recommended). JIT disabled by default due to unreliable cost estimates. LZ4 becomes the default TOAST compression when supported by the build.
Why it matters
Less downtime: REPACK CONCURRENTLY shrinks or removes maintenance windows to reclaim space and reorder data. On big tables, that’s gold.
Planner control without code changes: handy when OLTP and OLAP coexist and the “best” plan depends on real workload. You get fine-grained dials without patching the app.
Replica read consistency: WAIT FOR LSN provides clean read-your-writes on standbys. Fewer “sleep N ms” hacks.
Defaults with bite: JIT off may shift CPU/latency profiles; LZ4 in TOAST changes storage/CPU trade-offs; MD5 warnings nudge you to SCRAM.
Impact on your architecture
- High-churn OLTP: concurrent REPACK to fight bloat without traffic freezes.
- Mixed OLAP: planner advice can tame unruly queries.
- Replica reads: WAIT FOR LSN enables cleaner read-your-writes patterns.
- Security: SNI helps when certs vary by hostname.
What I’d do
- Don’t jump critical prod to 19.0 blind. The community’s classic advice still applies: for critical systems, wait for the .1 release. If 19 solves a pain, run a parallel pilot.
- Compatibility plan: staging with your extensions and used features. Review auth (move to SCRAM), JIT default off, and TOAST’s LZ4.
- Load tests: real OLTP/OLAP workloads. Compare plans with/without
pg_plan_advice. Watch async I/O and WAL inEXPLAIN ANALYZE. - Maintenance: replace
VACUUM FULL/CLUSTERwithREPACK CONCURRENTLYwhere it fits. Revisit autovacuum strategy given its new prioritization. - Replication: validate sequences with logical replication, and use WAIT FOR LSN where read consistency matters.
- Dev: leverage
INSERT ... ON CONFLICT DO SELECTfor upserts-with-reads; try COPY to JSON in pipelines.
My read: 19 brings real operational relief and useful planner dials, but upgrading a critical DB without rehearsal is asking Murphy to deploy. Pilot, measure, then decide. Has your team tried hot REPACK on large tables yet?
PS: if your DBA smiles on a Monday, they probably ran REPACK CONCURRENTLY on Sunday.