PostgreSQL 19 introduces REPACK to defragment tables without blocking reads or writes
PostgreSQL 19, currently in beta, introduces a new REPACK command that rewrites bloated tables to reclaim space, combining the functionality of VACUUM FULL and CLUSTER into a single tool. Its key feature is a CONCURRENTLY option that keeps the table readable and writable during the rewrite by building a new copy in the background and using logical decoding to capture changes. Benchmarks show REPACK (CONCURRENTLY) allowed nearly 4,000 writes and 384 reads during a rewrite, compared to just 33 writes and 1 read under VACUUM FULL, which holds an ACCESS EXCLUSIVE lock for its entire duration. The trade-off is speed: the concurrent mode took about 4.3 seconds versus under 1 second for VACUUM FULL, making plain REPACK preferable when a maintenance window is available. PostgreSQL 19 also ships a companion view, pg_stat_progress_repack, allowing administrators to monitor the rewrite phase in real time.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in