PostgreSQL 19 Adds REPACK and Replica Read Controls

PostgreSQL 19 introduces built-in table repacking, query plan advice, and a command for waiting on replica updates.

PostgreSQL 19 Adds REPACK and Replica Read Controls

PostgreSQL 19 arrived on November 19 with new controls for table maintenance, query planning, and replication. The release adds a built-in REPACK command, alongside extensions for influencing execution plans.

REPACK reclaims space, with locking limits

postgresql 19 how repack works

REPACK rewrites a table to reclaim disk space and reorganize its contents. Administrators can also order rows using an index.

REPACK (CONCURRENTLY) keeps reads and writes running during the main operation. PostgreSQL captures intervening changes through logical decoding, then applies them before swapping the rewritten files into place.

The final swap still requires an ACCESS EXCLUSIVE lock. Concurrent repacking therefore reduces disruption without removing locking altogether. The documentation also flags an MVCC limitation: transactions using snapshots taken before the rewrite see the table as empty after the operation commits.

WAIT coordinates reads on standbys

WAIT coordinates reads on standbys

The new WAIT command lets an application wait for a specified write-ahead log position. Waiting for standby replay helps a replica serve a read after the relevant write has reached and been applied on that replica.

Applications must supply the target log position. Waiting for WAL receipt or disk flush alone does not establish whether a query will see the updated rows.

Elsewhere, pg_plan_advice provides control over planner decisions, while pg_stash_advice applies saved advice automatically. PostgreSQL 19 also adds logical replication of sequence values and parallel autovacuum processing for table indexes.

Upgrading from an earlier major version requires pg_upgrade, dump and restore, or logical replication. The release notes list compatibility changes requiring review before migration.

Comments (0)