Re: Improving planning of outer joins

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Improving planning of outer joins
Date: 2005-12-16 20:12:43
Message-ID: 20051216201243.GA27602@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)) leftjoin A on (Pab)

?

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-12-16 20:18:04 Re: Improving planning of outer joins
Previous Message Martijn van Oosterhout 2005-12-16 19:54:37 Re: Web archive issue?