Unix Technical Forum

update, truncate and vacuum

This is a discussion on update, truncate and vacuum within the Pgsql Performance forums, part of the PostgreSQL category; --> Hi, I have a couple questions about how update, truncate and vacuum would work together. 1) If I update ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 11:17 AM
Scott Feldstein
 
Posts: n/a
Default 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)

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?

thanks,
Scott

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 11:17 AM
Dave Dutcher
 
Posts: n/a
Default Re: update, truncate and vacuum

> 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.

Dave


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:25 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com