Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 77B149FB7D2 for ; Tue, 10 Apr 2007 10:37:58 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 01142-02 for ; Tue, 10 Apr 2007 10:37:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sweeper01.cranel.com (newmail.cranel.com [66.192.200.227]) by postgresql.org (Postfix) with ESMTP id 24BC09FB3E4 for ; Tue, 10 Apr 2007 10:37:37 -0300 (ADT) Received: from POSTOFFICE.cranel.local (unverified [192.168.1.39]) by sweeper01.cranel.com (Clearswift SMTPRS 5.2.5) with ESMTP id for ; Tue, 10 Apr 2007 09:36:30 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message Subject: Re: DELETE with filter on ctid MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Tue, 10 Apr 2007 09:37:34 -0400 Message-ID: <82E74D266CB9B44390D3CCE44A781ED90B6ADE@POSTOFFICE.cranel.local> In-Reply-To: <461AB6CF.3060202@modgraph-usa.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PERFORM] DELETE with filter on ctid Thread-Index: Acd68SFtIDtu/PoLTTSsByDBxRdEmgAg/3cg From: "Spiegelberg, Greg" To: "Craig A. James" Cc: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/227 X-Sequence-Number: 24104 Craig, I'm not using a TEMP TABLE in this DELETE however I have tried an ANALYZE prior to the DELETE but it hardly makes a dent in the time. Please look at the other follow-up email I just sent for full details. Greg =20 -----Original Message----- From: Craig A. James [mailto:cjames@modgraph-usa.com]=20 Sent: Monday, April 09, 2007 5:58 PM To: Spiegelberg, Greg Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] DELETE with filter on ctid 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