Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 19CE79FA100 for ; Sun, 3 Dec 2006 14:24:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 88705-07 for ; Sun, 3 Dec 2006 14:24:10 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id C12C29F9F0E for ; Sun, 3 Dec 2006 14:24:22 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id kB3IOJ64021634; Sun, 3 Dec 2006 13:24:19 -0500 (EST) To: apb18@cornell.edu cc: pgsql-performance@postgresql.org Subject: Re: Propagating outer join conditions In-reply-to: <19ab0ccd0612030711s70a3e095hceb69509cbd41597@mail.gmail.com> References: <19ab0ccd0612030711s70a3e095hceb69509cbd41597@mail.gmail.com> Comments: In-reply-to "Aaron Birkland" message dated "Sun, 03 Dec 2006 10:11:30 -0500" Date: Sun, 03 Dec 2006 13:24:19 -0500 Message-ID: <21633.1165170259@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/32 X-Sequence-Number: 22088 "Aaron Birkland" writes: > ... Is is possible to generate a plan that looks like this: > Nested Loop Left Join (cost=???) > -> Index Scan using t28_o on t28 (cost=0.00..9.11 rows=1 width=89) > Index Cond: (o = '"spec"'::text) > -> Nested Loop (cost=???) > -> Index Scan using t1_s on t1 (cost=???) > Index Cond: (s = t28.s) > -> Bitmap Heap Scan on t11 (cost=???) > Recheck Cond: (t11.s = t1.o) > Filter: (o = ''::text) > -> Bitmap Index Scan on t11_s (cost=??? ) > Index Cond: (t11.s = t1.o) No. It'd take massive work in both the planner and executor to support something like that --- they are designed around the assumption that nestloop with inner index scan is exactly that, just one indexscan on the inside of the loop. (As of 8.2 there's some klugery to handle an Append of indexscans too, but it won't generalize readily.) It might be something to work on for the future, but I can see a couple of risks to trying to support this type of plan: * exponential growth in the number of plans the planner has to consider; * greatly increased runtime penalty if the planner has underestimated the number of rows produced by the outer side of the nestloop. regards, tom lane