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)) leftjoin A on (Pab)

?

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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to