Re: how much disk space does a VACUUM FULL take?

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: john gale <john(at)smadness(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: how much disk space does a VACUUM FULL take?
Date: 2013-12-04 18:17:31
Message-ID: CAOR=d=1Og=Pb0g2fBet28bP6bkv7GPq5tPpp-xA78Hbn-1jVkA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 3, 2013 at 2:04 PM, john gale <john(at)smadness(dot)com> wrote:
>
> 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, 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?

Yes, starting with pgsql 9.0 vacuum full writes a new copy of the
table out while holding the old copy locked. If the new copy is going
to be small then it's not too big of a problem. If it will be large
then you need the space to write it out. Note that sometimes making a
tablespace on another drive with enough room for the table to fit on
twice and using that can be helpful.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vincent Veyron 2013-12-04 21:29:40 Re: Need help with upsert
Previous Message Eric Lamer 2013-12-04 18:10:34 Re: Need help with upsert