Re: Planner creating ineffective plans on LEFT OUTER joins - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Planner creating ineffective plans on LEFT OUTER joins
Date
Msg-id 3353.1214447769@sss.pgh.pa.us
Whole thread Raw
In response to Planner creating ineffective plans on LEFT OUTER joins  (Andres Freund <andres@anarazel.de>)
Responses Re: Planner creating ineffective plans on LEFT OUTER joins
Re: Planner creating ineffective plans on LEFT OUTER joins
List pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> SELECT *
> FROM
>     ab LEFT OUTER JOIN (
>         bc JOIN cd
>         ON bc.c = cd.d
>     )
>     ON ab.b = bc.b
> WHERE
>     ab.a = 20000

> As ab.a = 20000 occurs only once in ab one would expect that it just does an 
> index scan on bc for ab.b = bc.b.

The only way it could do that would be by interchanging the order of the
left and inner joins, ie (ab left join bc) join cd; which would change
the results.

I believe it could interchange the joins if they were both LEFT or
both INNER.  Do you really need exactly these semantics?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Jan Urbański
Date:
Subject: Re: Creating a VIEW with a POINT column
Next
From: Bruce Momjian
Date:
Subject: Re: Proposed Patch - LDAPS support for servers on port 636 w/o TLS