Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 8825F9FB317 for ; Thu, 26 Jul 2007 20:59:33 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 60000-07 for ; Thu, 26 Jul 2007 20:59:13 -0300 (ADT) X-Greylist: delayed 00:59:59.079179 by SQLgrey-1.7.5 Received: from globalrelay.com (mail1.globalrelay.com [204.92.49.200]) by postgresql.org (Postfix) with ESMTP id 719899FB284 for ; Thu, 26 Jul 2007 20:59:29 -0300 (ADT) X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway X-GR-Acctd: YES Received: from [209.150.195.161] (HELO davedell) by globalrelay.com (CommuniGate Pro SMTP 4.2.3) with ESMTP id 150376422; Thu, 26 Jul 2007 15:59:28 -0700 From: "Dave Dutcher" To: "'Scott Feldstein'" , References: Subject: Re: update, truncate and vacuum Date: Thu, 26 Jul 2007 17:59:58 -0500 Message-ID: <073e01c7cfd8$b0d9d560$2e00a8c0@tridecap.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcfP1sIdlTS8ILn+T+qVCOqhqSHdfgAAXttg X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 In-Reply-To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200707/379 X-Sequence-Number: 26063 > 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