Re: Planner creating ineffective plans on LEFT OUTER joins

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Planner creating ineffective plans on LEFT OUTER joins
Date: 2008-06-26 02:36:09
Message-ID: 3353.1214447769@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)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

In response to

Responses

Browse pgsql-hackers by date

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