Craig Kerstiens shrank a 493 MB PostgreSQL test table to 228 MB three ways. The fastest method took 2.7 seconds and blocked reads and writes the whole time. The concurrent rewrite took 9.4 seconds and kept the table usable for most of the run.

  • Routine VACUUM makes room inside the table for future writes. A rewrite can give that space back to the operating system.
  • VACUUM FULL and plain REPACK hold an exclusive lock through the rewrite. REPACK (CONCURRENTLY) copies the table, replays writes from the database log, then takes an exclusive lock to finish replay and swap the files.
  • Budget disk space for a second copy of the table and indexes. PostgreSQL’s docs also warn that a transaction using a snapshot from before the rewrite can see an empty table after the swap.

Pick the method around the workload’s tolerance for blocked queries, not the benchmark’s fastest time. On a busy table, measure the final lock phase under a realistic write load before counting on it to be brief.