Skip site navigation (1) Skip section navigation (2)

Re: vacuum on empty table takes very long

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Anj Adu <fotographs(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: vacuum on empty table takes very long
Date: 2009-08-19 16:32:21
Message-ID: dcc563d10908190932h6e8b9f0cu46f9ee3434bc0874@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
On Tue, Aug 18, 2009 at 11:44 AM, Anj Adu<fotographs(at)gmail(dot)com> wrote:
> We have a partitioned table structure where the partitions are created
> on a daily basis. One of the inserts into the daily partition failed
> (crashed) ..the partition was empty after the crash.  We did a vacuum
> of the partition and it takes very long (over  30 minutes).
>
> Postgres 8.1.2  ... vacuum_cost_delay = 0.

You need an update.  You're missing years and years of bug fixes with
that version.

> What is vacuum doing that takes so long on an empty table?

Deleting tuples that aren't there.  You're probably better off using truncate:

begin;
trunctate only partition_table;
commit;

It's much faster.  The begin / commit pair are just in case you do it
to the wrong table you can get your data back replacing commit with
rollback.

In response to

pgsql-admin by date

Next:From: ml mlDate: 2009-08-19 17:39:05
Subject: Please have a look at my PITR and verify script....
Previous:From: Kevin KempterDate: 2009-08-19 14:56:25
Subject: help tuning query

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group