Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 333FDF64990 for ; Tue, 24 Jul 2012 14:13:05 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1StifO-00071w-Pt for pgsql-performance@postgresql.org; Tue, 24 Jul 2012 17:13:04 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q6OHCkeo024102; Tue, 24 Jul 2012 13:12:46 -0400 (EDT) From: Tom Lane To: Thomas Kellerer cc: pgsql-performance@postgresql.org Subject: Re: Using ctid column changes plan drastically In-reply-to: References: <21308.1343139781@sss.pgh.pa.us> <22819.1343145325@sss.pgh.pa.us> Comments: In-reply-to Thomas Kellerer message dated "Tue, 24 Jul 2012 18:32:09 +0200" Date: Tue, 24 Jul 2012 13:12:46 -0400 Message-ID: <24101.1343149966@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/306 X-Sequence-Number: 47487 Thomas Kellerer writes: > Tom Lane wrote on 24.07.2012 17:55: >> FWIW, it might be helpful to cast this as a NOT EXISTS rather than >> NOT IN subquery. > Hmm. How would you change that into an NOT EXISTS clause (so that one of the duplicates remains) > Everything I come up with is in fact slower than the NOT IN solution. Well, it would only help if you're running a PG version that's new enough to recognize the NOT EXISTS as an anti-join; and even then, it's possible that joining on a tid column forecloses enough plan types that you don't get any real benefit. But I'm just guessing. Can you show exactly what you tried and what EXPLAIN ANALYZE results you got? regards, tom lane