Re: Improving planning of outer joins - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Improving planning of outer joins
Date
Msg-id 20051216201243.GA27602@surnet.cl
Whole thread Raw
In response to Improving planning of outer joins  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Improving planning of outer joins
List pgsql-hackers
Tom Lane wrote:
> I've spent some time looking into how we can improve our planning of outer
> joins.  The current planner code slavishly follows the syntactic join
> order, which can lead to quite bad plans.  The reason it does this is that
> in some cases altering the join order of outer joins can change the
> results.  However, there are many cases where the results would not be
> changed, and we really need to start taking advantage of those cases.

I wonder if the code is already able to transform right joins to left
joins, like(A rightjoin B on (Pab)) = (B leftjoin A on (Pab))

I haven't looked at the code but I vaguely remember it is possible with
some strings attached, like not being able to use not-mergejoinable
conditions or something.  I imagine it shows up as a leftjoin node with
some flag set.

How does this affect this optimization?  Does this hold:

(A rightjoin B on (Pab)) innerjoin C on (Pbc)= (B leftjoin A on (Pab)) innerjoin C on (Pbc)= (B innerjoin C on (Pbc))
leftjoinA on (Pab)
 

?

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


pgsql-hackers by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Web archive issue?
Next
From: Tom Lane
Date:
Subject: Re: Improving planning of outer joins