Skip to content
Techlogue
Subscribe

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.

2 min read

Share
Colored tiles scattered in one wooden tray are packed into a compact block in another.
Image: Techlogue · AI-generated editorial illustration

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

Be the first to react Join the discussion

Comments 0

Sign in to like, comment and reply.

Sign in to comment

No comments yet. Be the first to comment.

Newsletter

New guides, straight to your inbox.

One email when we publish something worth your time. Practical, hands-on, and never more than once a week.

No spam. Unsubscribe with one click. See our privacy policy.