From: Mark Steben <msteben@autorevenue.com>
To: pgsql-performance@postgresql.org
Subject: question on TRUNCATE vs VACUUM FULL
Date: Tue, 18 Mar 2008 17:06:45 -0400
Message-ID: <00f701c8893b$f9545af0$14010a0a@dei26g028575> (raw)
Hi folks,
We are running Postgres 8.2.5.
I have 3 tables, call them A, B, and C
Table A houses info on all emails that have ever been created for the
purpose of being delivered to our end customers.
Big table. About 23 million rows.
Table B, the 'holding' table is populated with Table A key information via
an after trigger whenever Table A is updated or inserted to.
Table C, the 'work' table is populated by function D from table B. It is
configured exactly like table B.
PLPGSQL Function D inserts a predefined number of rows from table B to
table C. For purposes of discussion, say 500.
Function D, after it does its thing, then deletes the 500 rows it
processed from table B, and ALL 500 rows from table C.
This entire process, after a sleep period of 10 seconds, repeats itself all
day.
After each fifth iteration of function D, we perform a VACUUM FULL on both
tables B and C.
Takes less than 5 seconds.
In terms of transaction processing:
Table A is processed by many transactions (some read, some update),
Table B is processed by
- any transaction updating or inserting to Table A via the after
trigger (insert, update)
- Function D (insert, update, delete)
Table C is processed ONLY by function D (insert, update, delete). Nothing
else touches it;
PG_LOCKS table verifies that that this table is totally free of any
transaction
Between iterations of function D.
So my question is this: Shouldn't VACUUM FULL clean Table C and reclaim all
its space?
It doesn't. It usually reports the same number of pages before and after
the Vacuum.
We have to resort to TRUNCATE to clean and reclaim this table, which
Must be empty at the beginning of function D.
Any insights appreciated. Thanks,
Mark Steben
Senior Database Administrator
@utoRevenueT
A Dominion Enterprises Company
480 Pleasant Street
Suite B200
Lee, MA 01238
413-243-4800 Home Office
413-243-4809 Corporate Fax
msteben <blocked::mailto:name@autorevenue.com> @autorevenue.com
Visit our new website at
<blocked::http://www.autorevenue.com/; www.autorevenue.com
IMPORTANT: The information contained in this e-mail message is confidential
and is intended only for the named addressee(s). If the reader of this
e-mail message is not the intended recipient (or the individual responsible
for the delivery of this e-mail message to the intended recipient), please
be advised that any re-use, dissemination, distribution or copying of this
e-mail message is prohibited. If you have received this e-mail message in
error, please reply to the sender that you have received this e-mail message
in error and then delete it. Thank you.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: msteben@autorevenue.com
Subject: Re: question on TRUNCATE vs VACUUM FULL
In-Reply-To: <00f701c8893b$f9545af0$14010a0a@dei26g028575>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox