Re: VACUUM and ANALYZE With Empty Tables

From: Richard Huxton <dev(at)archonet(dot)com>
To: Mark Dexter <MDEXTER(at)dexterchaney(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: VACUUM and ANALYZE With Empty Tables
Date: 2004-11-24 09:26:31
Message-ID: 41A453C7.9090600@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mark Dexter wrote:
> We use a development environment that works with Postgres via ODBC and
> uses cursors to insert and update rows in Postgres tables. I'm using
> Postgres version 7.4.5.

> A. If I TRUNCATE or DELETE all of the rows in the table and then run
> VACUUM or ANALYZE on the empty table, the test program takes over 15
> minutes to complete (i.e., 15X performance drop).

> If we routinely run VACUUM or VACUUM ANALYZE (e.g., nightly), these work
> tables will normally be empty when the VACUUM is run. So it would
> appear from the testing above that they will experience performance
> problems when inserting large numbers of rows through our application.

Yep - it's a known issue. The analyse is doing what you asked, it's just
not what you want.

> Is there some easy way around this problem? If there a way to force
> VACUUM or ANALYZE to optimize for a set number of rows even if the table
> is empty when it is run? Thanks for your help. Mark

There are only two options I know of:
1. Vaccum analyse each table separately (tedious, I know)
2. Try pg_autovacuum in the contrib/ directory

The autovacuum utility monitors activity for you and targets tables when
they've seen a certain amount of activity. Even if it hasn't got the
tunability you need, it should be a simple patch to add a list of
"excluded" tables.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2004-11-24 09:52:26 Re: Upcoming Changes to News Server ...
Previous Message Richard Huxton 2004-11-24 09:03:48 Re: I need to add a column to a table