X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E6B059DC887 for ; Wed, 14 Dec 2005 11:26:57 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80662-01 for ; Wed, 14 Dec 2005 11:26:57 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id C1E6D9DC82E for ; Wed, 14 Dec 2005 11:26:48 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jBEFQrZP019523; Wed, 14 Dec 2005 10:26:53 -0500 (EST) To: francisco.santos@tagus.ist.utl.pt cc: pgsql-performance@postgresql.org Subject: Re: Convert IN sublink to join In-reply-to: <000001c600b2$1ccb44e0$017ba8c0@flintstone> References: <000001c600b2$1ccb44e0$017ba8c0@flintstone> Comments: In-reply-to message dated "Wed, 14 Dec 2005 13:27:21 +0000" Date: Wed, 14 Dec 2005 10:26:53 -0500 Message-ID: <19522.1134574013@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.002 required=5 tests=[AWL=0.002] X-Spam-Score: 0.002 X-Spam-Level: X-Archive-Number: 200512/329 X-Sequence-Number: 16150 writes: > /* > * The sub-select must not refer to any Vars of the parent query. > * (Vars of higher levels should be okay, though.) > */ > if (contain_vars_of_level((Node *) subselect, 1)) > return NULL; > By commenting this code region I was able to optimize several correlated > subqueries. It's only pure luck that your test case still produces the right answer. The IN code depends on the assumption that the sub-SELECT is independent of the outer query. regards, tom lane