Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2B44B476FB9 for ; Wed, 22 Jan 2003 20:21:20 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 382DB4760A2 for ; Wed, 22 Jan 2003 19:45:08 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 03759D616; Wed, 22 Jan 2003 16:45:10 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id ED4725C03; Wed, 22 Jan 2003 16:45:10 -0800 (PST) Date: Wed, 22 Jan 2003 16:45:10 -0800 (PST) From: Stephan Szabo To: Tom Lane Cc: Tomasz Myrta , Jan Wieck , Ries van Twisk , Subject: Re: To use a VIEW or not to use a View..... In-Reply-To: <24368.1043271333@sss.pgh.pa.us> Message-ID: <20030122164324.K4204-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/348 X-Sequence-Number: 11213 On Wed, 22 Jan 2003, Tom Lane wrote: > Stephan Szabo writes: > > The filter is applied only to a. So, if you really wanted the > > c.a=3 condition to be applied for whatever reason you're out of > > luck. > > FWIW, CVS tip is brighter: the condition does propagate to both relations. > > Hash Join (cost=22.51..45.04 rows=1 width=8) > Hash Cond: ("outer".a = "inner".a) > -> Seq Scan on a (cost=0.00..22.50 rows=5 width=4) > Filter: (a = 3) > -> Hash (cost=22.50..22.50 rows=5 width=4) > -> Seq Scan on c (cost=0.00..22.50 rows=5 width=4) > Filter: (3 = a) > > The reason this is useful is that (a) fewer rows need to be joined, > and (b) we may be able to make effective use of indexes on both tables. Yeah. I was going to ask how hard you thought it would be to do for this particular sort of case. I thought about the simple case of using and realized it'd probably be reasonable in amount of work, but it seems I don't have to think about it. :)