Postgres 19's REPACK lets you shrink bloated tables without taking them offline

Postgres 19 Repack: Faster, Built-In Table Bloat Cleanup

Postgres 19's REPACK lets you shrink bloated tables without taking them offline

Postgres 19 adds REPACK as a built-in SQL command, and its CONCURRENTLY mode reclaims bloated table space while the table stays fully readable and writable, taking only a brief lock at the end. It uses WAL-based logical decoding, the same approach as pg_squeeze, so no triggers or external binaries are needed. In one test, a 493 MB table shrank to 228 MB in 9.4 seconds, roughly 1.5 to 2 times slower than VACUUM FULL but without the downtime.

REPACK CONCURRENTLY is slower in wall-clock time. It's doing more work: logical decoding and WAL replay on top of the table rebuild. The tradeoff here is more time to keep your table online.
  1. jzelinskie

    I haven't used these extensions, but I like the direction of being able to extend Postgres by tailing its own internals (pg_squeeze approach) than triggers (pg_repack).

    We (the SpiceDB developers) took a similar approach to solve a different problem a few years ago: implementing strict serializability in Postgres[0]. By hooking into the transactions layer themselves (pg_xact), we could layer on our own MVCC reusing the real Postgres transactions to compute visibility and total ordering. When you can just tail the Postgres internals, you don't even need to implement a Postgres extension, which can keep it portable across locked-down, managed Postgres offerings.

    Do folks know of other clever implementations of behavior by "spying" on the Postgres internals?

    [0]: https://m.youtube.com/watch?v=_f6fHy4DWWM

  2. nopurpose

    They added plan hinting, but sadly not via comments. To use hinting an app needs to issue a `SET` command, which adds round trip latency for each query. Need to use quite unergonomic query batching/pipelining to negate that latency.

  3. inkysigma

    Isn't losing MVCC consistency a pretty big drawback? Am I misinterpreting or does that mean occasionally a query might just return nothing for possibly difficult to diagnose reasons?

More from this day

2026-11-20