PostgreSQL 19 gives a bloated table a second chance
The new REPACK command can return disk space while a busy table stays in use. Its temporary storage requirement matters most when that disk is already filling up.
Share

A service deletes a year’s worth of expired events, yet the database file still takes up much of the disk. PostgreSQL 19, released November 19, gives administrators a built-in way to rewrite that table. The release notes and command reference make a persuasive case for a specific job. It can recover storage from a table that people need to keep reading and updating. PostgreSQL 19 announcement
Why the spare disk matters
REPACK builds a new copy containing the live rows and rebuilds the indexes. Those copies explain the awkward part of the proposal. A 40 GB table with 10 GB of indexes needs at least another 50 GB free while the work runs. Sorting or capturing ongoing changes can require more. For a database close to its storage ceiling, finding that working space comes before any estimate of what the completed rewrite will save. Command reference
What concurrent really buys
With the concurrent option, readers and writers can carry on during most of the rewrite. PostgreSQL collects intervening changes and needs an exclusive lock at the end to swap the files. A subscriber-facing service should rehearse that final step under a representative write load. A long-running report deserves attention too. A transaction using a snapshot from before the rewrite began can see an empty table after it finishes. For a small archive with a dependable maintenance window, an ordinary rewrite may be the simpler choice. For a busy service with storage headroom, concurrent repacking earns a place in the maintenance plan. Concurrency notes
Comments 0
Sign in to like, comment and reply.
Sign in to commentNo comments yet. Be the first to comment.