X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A1F40D1B527 for ; Thu, 13 Nov 2003 15:20:19 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 53496-08 for ; Thu, 13 Nov 2003 11:19:51 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 63DA9D1B4FE for ; Thu, 13 Nov 2003 11:19:47 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hADFJp19026332; Thu, 13 Nov 2003 10:19:52 -0500 (EST) To: Rajesh Kumar Mallah Cc: pgsql-performance@postgresql.org Subject: Re: IN surpasses NOT EXISTS in 7.4RC2 ?? In-reply-to: <200311131323.39762.mallah@trade-india.com> References: <200311131323.39762.mallah@trade-india.com> Comments: In-reply-to Rajesh Kumar Mallah message dated "Thu, 13 Nov 2003 13:23:39 +0530" Date: Thu, 13 Nov 2003 10:19:51 -0500 Message-ID: <26331.1068736791@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/86 X-Sequence-Number: 4646 Rajesh Kumar Mallah writes: > NOT EXISTS is taking almost double time than NOT IN . > I know IN has been optimised in 7.4 but is anything > wrong with the NOT EXISTS? That's the expected behavior in 7.4. EXISTS in the style you are using it effectively forces a nestloop-with-inner-indexscan implementation. As of 7.4, IN can do that, but it can do several other things too, including the hash-type plan you have here. So assuming that the planner chooses the right plan choice (not always a given ;-)) IN should be as fast or faster than EXISTS in all cases. regards, tom lane