Skip to content
ÁgilNews Belém, Pará PT-BR
Databases

PostgreSQL 19 can repack tables while applications keep using them

REPACK reclaims disk space. Its CONCURRENTLY option keeps a table available for reads and writes through most of the work, though the final swap still requires an exclusive lock.

AI-generated illustration of a blue elephant stacking green and yellow paper disks.

A table with frequent updates and deletes can take up far more disk space than its live data requires. PostgreSQL 19, released on November 19, introduces REPACK to rewrite it. For a team running a sales application, the practical benefit is reclaiming storage without locking users out of the table for the entire copy.

How much space to reserve and when the lock matters

With CONCURRENTLY, the application can read and write while the database builds new files. At the end, PostgreSQL needs exclusive access to apply outstanding changes and swap the files. How long that takes depends on how many changes have accumulated.

Teams should budget free space at least equal to the table and its indexes combined. An 80 GB table with 20 GB of indexes needs at least 100 GB free for the copy. Sorting by an index may require more. The documentation also warns that transactions using a snapshot taken before the operation began can see an empty table after the swap.

Sources