question on TRUNCATE vs VACUUM FULL - Mailing list pgsql-performance

From Mark Steben
Subject question on TRUNCATE vs VACUUM FULL
Date
Msg-id 00f701c8893b$f9545af0$14010a0a@dei26g028575
Whole thread Raw
Responses Re: question on TRUNCATE vs VACUUM FULL  (Chris <dmagick@gmail.com>)
List pgsql-performance

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
@utoRevenue™
A Dominion Enterprises Company
480 Pleasant Street
Suite B200
Lee, MA 01238
413-243-4800 Home Office 
413-243-4809 Corporate Fax

msteben@autorevenue.com

Visit our new website at
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.

 

pgsql-performance by date:

Previous
From: Gregory Stark
Date:
Subject: Re: What is the best way to storage music files in Postgresql
Next
From: "Stephen Denne"
Date:
Subject: Re: Planner mis-estimation using nested loops followup