Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

PostgreSQL Table Bloat and Defragmentation: Autovacuum vs. VACUUM vs. VACUUM FULL

Standard PostgreSQL vacuum makes dead-row space reusable; VACUUM FULL rewrites a table to reclaim physical disk space, at the cost of an exclusive lock and temporary capacity.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use autovacuum or standard VACUUM to clean up dead row versions and make their space reusable inside PostgreSQL. Use VACUUM FULL only when you need to compact a table file and return space to the operating system—and can accommodate its exclusive lock, extra disk use, and I/O. The right choice depends on what “reclaim space” means for your workload.

What PostgreSQL table bloat means for disk space

An UPDATE or DELETE can leave old row versions that are no longer needed. Vacuuming removes reclaimable dead versions and makes their space available for reuse. That does not necessarily make the table’s relation file smaller: standard vacuum usually leaves the space in the file so PostgreSQL can use it for later rows in the same table.

As an Amazon Associate I earn from qualifying purchases.

So there are two different goals:

  • Reuse capacity within the table: routine autovacuum or standard VACUUM is normally appropriate.
  • Reduce the relation file and return space to the operating system: a table rewrite such as VACUUM FULL may be needed.

There is no universal bloat percentage or size threshold that makes a rewrite worthwhile for every workload. Consider whether the space can be reused, whether the table is likely to grow back, and the operational cost of rewriting it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How the three maintenance options differ

Approach Main effect Does it return space to the operating system? Concurrency and workload considerations Best fit
Autovacuum Automatically schedules routine vacuum and analyze work. Usually not; eligible empty pages at the relation’s end may be truncated. Runs in the background. Vacuum I/O can affect other work, and cost settings can reduce its impact. Ongoing maintenance; tune for table size and churn where needed.
Standard VACUUM Removes dead row versions and makes their space reusable. Usually not; it may truncate completely empty pages at the end of the table. Ordinarily permits normal reads and writes, though vacuum can generate substantial I/O. End-page truncation may require an ACCESS EXCLUSIVE lock. Routine cleanup or a manual catch-up when space can be reused inside the table.
VACUUM FULL Rewrites the table into a compact new file. Yes, when successful. Slower, requires temporary room for the new copy while the old copy remains, and holds an ACCESS EXCLUSIVE lock. Planned, exceptional physical shrink when the returned disk space justifies the disruption.

PostgreSQL’s VACUUM command documentation describes the command’s behavior and options. Its routine vacuuming guidance explains why standard vacuum is recurring maintenance rather than a command to minimize every table file.

What autovacuum does—and what it does not do

Autovacuum is PostgreSQL’s background facility for scheduling VACUUM and ANALYZE. In PostgreSQL 18 it is enabled by default, but track_counts must also be enabled for the statistics autovacuum uses. It does not run VACUUM FULL; its purpose is regular maintenance, not compacting each table to its smallest possible size.

For PostgreSQL 18, documented defaults include three simultaneous autovacuum workers, a one-minute minimum delay between runs on a database, a vacuum threshold of 50 updated or deleted tuples, and a vacuum scale factor of 0.2. The trigger combines the threshold with a fraction of table size, subject to a documented maximum threshold. These are defaults, not universal tuning recommendations. Large or frequently updated tables may need table-specific threshold or scale-factor settings.

Autovacuum also helps protect against transaction ID wraparound. PostgreSQL can start vacuum workers for this safety purpose even if autovacuum is otherwise disabled, so disabling the daemon is not a solution to bloat. Review the version-specific vacuuming configuration documentation before changing settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What standard VACUUM accomplishes

Standard VACUUM cleans up dead row versions in tables and indexes and marks the resulting space reusable. It ordinarily runs alongside normal reads and writes. It usually does not shrink the relation file, although PostgreSQL may truncate completely empty pages at the physical end of a table when it can acquire the needed lock. The vacuum_truncate setting or the command’s TRUNCATE option can disable that end-page truncation when avoiding its lock is more important than reclaiming those pages.

Vacuum is not merely a defragmentation operation. It updates the visibility map, which supports index-only scans, and freezes old rows as part of transaction ID maintenance. Planner statistics are maintained by ANALYZE, which autovacuum schedules and which can also be run separately; vacuuming and statistics collection address related but distinct maintenance needs.

Vacuum can create substantial I/O. PostgreSQL provides cost-based delay settings to reduce interference with concurrent work; choose the trade-off based on workload and service objectives rather than assuming vacuum is cost-free.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When VACUUM FULL is justified

Choose VACUUM FULL when reducing the physical table file is a real requirement—for example, when reclaimed disk capacity matters more than continued access to that table during the rewrite. It copies live data into a new compact file, so the old and new copies coexist until the operation finishes. Confirm that the filesystem has enough temporary headroom and schedule for an ACCESS EXCLUSIVE lock, which prevents concurrent use of the table while the command runs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

It is usually a poor recurring strategy for a table that will quickly consume the freed space again. PostgreSQL’s routine-vacuuming guidance states: “The usual goal of routine vacuuming is to do standard VACUUMs often enough to avoid needing VACUUM FULL.”

CLUSTER and some ALTER TABLE operations also rewrite a table and its indexes. They have their own semantics, require temporary space, and take an ACCESS EXCLUSIVE lock; they are not lock-free substitutes for VACUUM FULL.

A practical decision sequence

  1. Identify the problem. Decide whether you need dead-row cleanup, a smaller physical relation file, refreshed planner statistics, or protection from transaction ID age. Vacuum-related operations serve different parts of this list.
  2. If internal reuse is enough, allow autovacuum to work or run standard VACUUM for a manual catch-up. Do not expect ordinary vacuum to shrink the file in most cases.
  3. If physical shrink is required, evaluate the expected benefit against temporary disk capacity, I/O, and the time the table will be unavailable under the exclusive lock before running VACUUM FULL.
  4. For recurring high churn, check autovacuum and track_counts, then review table-specific thresholds and scale factors rather than repeatedly rewriting the table.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.