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

Re: update, truncate and vacuum

From: "Dave Dutcher" <dave(at)tridecap(dot)com>
To: "'Scott Feldstein'" <scott(dot)feldstein(at)hyperic(dot)com>,<pgsql-performance(at)postgresql(dot)org>
Subject: Re: update, truncate and vacuum
Date: 2007-07-26 22:59:58
Message-ID: 073e01c7cfd8$b0d9d560$ (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
> From: Scott Feldstein
> Subject: [PERFORM] update, truncate and vacuum
> Hi,
> I have a couple questions about how update, truncate and 
> vacuum would work together.
> 1) If I update a table foo (id int, value numeric (20, 6)) 
> with update foo set value = 100 where id = 1
> Would a vacuum be necessary after this type of operation 
> since the updated value is a numeric? (as opposed to a sql 
> type where its size could potentially change i.e varchar)

Yes a vacuum is still necessary.  The type doesn't really matter.  Postgres
effectively does a delete and insert on all updates.

> 2) After several updates/deletes to a table, if I truncate 
> it, would it be necessary to run vacuum in order to reclaim the space?

No a vacuum is not necessary after a truncate because the whole data file is
deleted once a truncate commits.  There aren't any dead rows because there
aren't any rows.


In response to

pgsql-performance by date

Next:From: Luke LonerganDate: 2007-07-26 23:17:32
Subject: Re: update, truncate and vacuum
Previous:From: Scott FeldsteinDate: 2007-07-26 22:36:50
Subject: update, truncate and vacuum

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