Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 6DB5D9FB64B for ; Mon, 9 Apr 2007 18:50:51 -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 05580-03 for ; Mon, 9 Apr 2007 18:50:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from 66-226-76-106.dedicated.abac.net (66-226-76-106.dedicated.abac.net [66.226.76.106]) by postgresql.org (Postfix) with ESMTP id 8A8649FB4F7 for ; Mon, 9 Apr 2007 18:50:47 -0300 (ADT) Received: (qmail 7970 invoked by uid 2020); 9 Apr 2007 14:50:45 -0700 Received: from wsip-70-167-125-69.sd.sd.cox.net (HELO ?192.168.0.3?) (70.167.125.69) by 192.168.0.4 with (DHE-RSA-AES256-SHA encrypted) SMTP; 9 Apr 2007 14:50:45 -0700 Message-ID: <461AB6CF.3060202@modgraph-usa.com> Date: Mon, 09 Apr 2007 14:57:35 -0700 From: "Craig A. James" User-Agent: Thunderbird 1.5.0.10 (X11/20070221) MIME-Version: 1.0 To: "Spiegelberg, Greg" CC: pgsql-performance@postgresql.org Subject: Re: DELETE with filter on ctid References: <82E74D266CB9B44390D3CCE44A781ED90B6ADC@POSTOFFICE.cranel.local> In-Reply-To: <82E74D266CB9B44390D3CCE44A781ED90B6ADC@POSTOFFICE.cranel.local> 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=2.59 tagged_above=0 required=5 tests=AWL=-1.229, BAYES_50=0.001, HELO_DYNAMIC_IPADDR2=3.818 X-Spam-Level: ** X-Archive-Number: 200704/219 X-Sequence-Number: 24096 Spiegelberg, Greg wrote: > We have a query which generates a small set of rows (~1,000) which are > to be used in a DELETE on the same table. The problem we have is that > we need to join on 5 different columns and it takes far too long. You may have encountered the same problem I did: You *must* run ANALYZE on a temporary table before you use in another query. It's surprising that this is true even for very small tables (a few hundred to a few thousand rows), but it is. I had a case where I created a "scratch" table like yours, and the before/after ANALYZE performance was the difference between 30 seconds and a few milliseconds for the same query. Craig