Re: [HACKERS] inner join removal

2010-07-08 Thread Tom Lane
Robert Haas writes: > On Thu, Jul 8, 2010 at 3:05 PM, Tom Lane wrote: >> Right, but look for example at the logic involved with the current outer >> join transformation identity #3, which can't be applied unless the join >> predicate is strict for the left-hand side.  We avoid doing the dogwork >

Re: [HACKERS] inner join removal

2010-07-08 Thread Robert Haas
On Thu, Jul 8, 2010 at 3:05 PM, Tom Lane wrote: > Robert Haas writes: >> On Thu, Jul 8, 2010 at 2:48 PM, Tom Lane wrote: >>> I think it might work out better if you ask "what >>> additional conditions are needed in order to prove that this inner join >>> can commute with this left join", and the

Re: [HACKERS] inner join removal

2010-07-08 Thread Josh Berkus
I think it might work out better if you ask "what > additional conditions are needed in order to prove that this inner join > can commute with this left join", and then work at being able to prove > that. (It's entirely likely that the planner isn't currently gathering > the right information fo

Re: [HACKERS] inner join removal

2010-07-08 Thread Tom Lane
Robert Haas writes: > On Thu, Jul 8, 2010 at 2:48 PM, Tom Lane wrote: >> I think it might work out better if you ask "what >> additional conditions are needed in order to prove that this inner join >> can commute with this left join", and then work at being able to prove >> that.  (It's entirely

Re: [HACKERS] inner join removal

2010-07-08 Thread Robert Haas
On Thu, Jul 8, 2010 at 2:48 PM, Tom Lane wrote: > Robert Haas writes: >> Consider: > >> SELECT * FROM foo LEFT JOIN (bar JOIN baz ON bar.y = baz.y) ON foo.x = bar.x; > >> If foo is itty bitty and bar and baz are enormous, it would be nice to >> start by joining foo to bar and then joining the res

Re: [HACKERS] inner join removal

2010-07-08 Thread Tom Lane
Robert Haas writes: > Consider: > SELECT * FROM foo LEFT JOIN (bar JOIN baz ON bar.y = baz.y) ON foo.x = bar.x; > If foo is itty bitty and bar and baz are enormous, it would be nice to > start by joining foo to bar and then joining the result to baz, but > that's not legal. However, if bar (y)

[HACKERS] inner join removal

2010-07-08 Thread Robert Haas
So I sat down to work on some code to do inner join removal, and quickly got stuck. As a first step, I wanted to write some code that would identify inner joins that could be treated as LEFT JOINs if we so chose. Consider: SELECT 1 FROM foo, bar WHERE foo.x = bar.x; If it so happens that there