Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 482F4B5DC03 for ; Mon, 5 Sep 2011 06:27:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 12362-07 for ; Mon, 5 Sep 2011 09:27:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qw0-f44.google.com (mail-qw0-f44.google.com [209.85.216.44]) by mail.postgresql.org (Postfix) with ESMTP id 9D846B5DC50 for ; Mon, 5 Sep 2011 06:27:07 -0300 (ADT) Received: by qwg2 with SMTP id 2so3488794qwg.17 for ; Mon, 05 Sep 2011 02:27:07 -0700 (PDT) Received: by 10.229.177.168 with SMTP id bi40mr2905659qcb.161.1315214827510; Mon, 05 Sep 2011 02:27:07 -0700 (PDT) Received: from [10.1.1.8] (124-169-102-162.dyn.iinet.net.au. [124.169.102.162]) by mx.google.com with ESMTPS id dt6sm5974496qab.9.2011.09.05.02.27.00 (version=SSLv3 cipher=OTHER); Mon, 05 Sep 2011 02:27:01 -0700 (PDT) Message-ID: <4E6495DE.2060601@ringerc.id.au> Date: Mon, 05 Sep 2011 17:26:54 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 MIME-Version: 1.0 To: C Pond CC: pgsql-performance@postgresql.org Subject: Re: Embedded VACUUM References: <1315009500.78128.YahooMailClassic@web112110.mail.gq1.yahoo.com> In-Reply-To: <1315009500.78128.YahooMailClassic@web112110.mail.gq1.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/29 X-Sequence-Number: 44805 On 3/09/2011 8:25 AM, C Pond wrote: > I'm running a labour-intensive series of queries on a medium-sized dataset (~100,000 rows) with geometry objects and both gist and btree indices. > > The queries are embedded in plpgsql, and have multiple updates, inserts and deletes to the tables as well as multiple selects which require the indices to function correctly for any kind of performance. > > My problem is that I can't embed a vacuum analyze to reset the indices and speed up processing, and the queries get slower and slower as the un-freed space builds up. > > From my understanding, transaction commits within batches are not allowed (so no vacuum embedded within queries). Are there plans to change this? Is there a way to reclaim dead space for tables that have repeated inserts, updates and deletes on them? Not, AFAIK, until the transaction doing the deletes/updates commits and so do any older SERIALIZABLE transactions as well as any older running READ COMMITTED statements. This is one of the areas where Pg's lack of true stored procedures bites you. You'll need to do the work via an out-of-process helper over a regular connection, or do your work via dblink to achieve the same effect. -- Craig Ringer