Re: how much disk space does a VACUUM FULL take? - Mailing list pgsql-general

From Andreas Brandl
Subject Re: how much disk space does a VACUUM FULL take?
Date
Msg-id 42be92dd-3d3b-4ff4-b8f9-0bd63f88d7bb@store1.zcs.ext.wpsrv.net
Whole thread Raw
In response to how much disk space does a VACUUM FULL take?  (john gale <john@smadness.com>)
Responses Re: how much disk space does a VACUUM FULL take?
List pgsql-general
John,

> Due to running low on disk space, we have recently removed a majority
> of rows from a table to an archival DB.
>
> Although VACUUM allows disk space to be re-used, VACUUM FULL is the
> only one that actively reclaims disk space for use by the OS.
>  http://www.postgresql.org/docs/9.0/static/routine-vacuuming.html
>
> For a variety of reasons I would prefer disk usage to be as low as
> possible, thus I would like to run a VACUUM FULL during some
> maintenance cycle (since it exclusively locks the table).  However,

you might want to consider setting fillfactor to 100 [1] to completely compact the table (before doing a VACUUM FULL).

Though I'm not 100% sure but I assume that VACUUM FULL considers the fillfactor when rewriting the table (maybe someone
cancomment on this?). 

> given the details of VACUUM FULL:
>
> > VACUUM FULL actively compacts tables by writing a complete new
> > version of the table file with no dead space. This minimizes the
> > size of the table, but can take a long time. It also requires
> > extra disk space for the new copy of the table, until the
> > operation completes.
>
> Does this suggest that VACUUM FULL needs free disk space on the order
> of the full size of the table that it's vacuuming to be able to
> complete?  Or does it / can it write the filesystem files in the 1GB
> chunks stored in /base while removing the new "unused" files at the
> same time, thus requiring only a few GB of free space?

AFAIK a VACUUM FULL frees the old data after having completely written the new version. So the size of the original
tableis an upper bound for the space requirement and it can be much less (in case the original table is bloated a lot). 

Regards,
Andreas

[1] http://www.postgresql.org/docs/9.1/static/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS


pgsql-general by date:

Previous
From: Steven Schlansker
Date:
Subject: Re: Timing for release with fix for "Nov2013ReplicationIssue"
Next
From: john gale
Date:
Subject: Re: how much disk space does a VACUUM FULL take?