Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 9D8ED9FB902 for ; Thu, 7 Jun 2007 18:27:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 00200-07 for ; Thu, 7 Jun 2007 18:26:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from crestone.coronasolutions.com (crestone.coronasolutions.com [66.45.104.24]) by postgresql.org (Postfix) with ESMTP id C6EFC9FB743 for ; Thu, 7 Jun 2007 18:27:00 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by crestone.coronasolutions.com (Postfix) with ESMTP id 7B0856447C7; Thu, 7 Jun 2007 15:26:58 -0600 (MDT) Received: from crestone.coronasolutions.com ([127.0.0.1]) by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13186-04; Thu, 7 Jun 2007 15:26:56 -0600 (MDT) Received: from mac.local (c-76-25-77-161.hsd1.co.comcast.net [76.25.77.161]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by crestone.coronasolutions.com (Postfix) with ESMTP id 818F96447D5 for ; Thu, 7 Jun 2007 15:26:56 -0600 (MDT) Message-ID: <46687820.9000604@drivefaster.net> Date: Thu, 07 Jun 2007 15:26:56 -0600 From: Dan Harris User-Agent: Thunderbird 2.0.0.0 (Macintosh/20070326) MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: reclaiming disk space after major updates References: <46672F7C.4020400@drivefaster.net> <20070607192025.GO14087@phlogiston.dyndns.org> In-Reply-To: <20070607192025.GO14087@phlogiston.dyndns.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at coronasolutions.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/73 X-Sequence-Number: 25741 Andrew Sullivan wrote: > On Wed, Jun 06, 2007 at 04:04:44PM -0600, Dan Harris wrote: >> of these operations or a full dump/reload. I do run VACUUM regularly, it's >> just that sometimes we need to go back and update a huge percentage of rows >> in a single batch due to changing customer requirements, leaving us with >> significant table bloat. > > Do you need to update those rows in one transaction (i.e. is the > requirement that they all get updated such that the change only > becomes visible at once)? If not, you can do this in batches and > vacuum in between. Batch updates are the prime sucky area in > Postgres. They don't always have to be in a single transaction, that's a good idea to break it up and vacuum in between, I'll consider that. Thanks > > Another trick, if the table is otherwise mostly static, is to do the > updating in a copy of the table, and then use the transactional DDL > features of postgres to change the table names. I thought of this, but it seems to break other application logic that feeds a steady streams of inserts into the tables. Thanks again for your thoughts. I guess I'll just have to work around this problem in application logic.