Re: [SQL] outer joins strangeness

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Alex Pilosov <alex(at)pilosoft(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [SQL] outer joins strangeness
Date: 2001-09-24 16:07:31
Message-ID: Pine.BSF.4.21.0109240902180.5229-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

On Mon, 24 Sep 2001, Alex Pilosov wrote:

> On Sun, 23 Sep 2001, Stephan Szabo wrote:
>
> > On Sun, 23 Sep 2001, Alex Pilosov wrote:
> >
> > Postgres treats join syntax as an explicit definition of what order to
> > joins in. So, I'd guess it sees the first as: do the LOJ and then join
> > that to the separate table.
> Yeah, I figure that's how it sees it, but that's pretty stupid from
> performance reasons :P)
>
> It _should_ realize that left outer join only constricts join order
> between two tables in outer join, and joins to all other tables should
> still be treated normally.
(see below)
>
> I'm going to CC this to -hackers, maybe someone will shed a light on the
> internals of this.
>
> > And for right outer join (for example), those two queries would not
> > be equivalent if I read the ordering correctly. The former syntax
> > would mean outer first and then the inner, whereas the second would
> > be inner first then the outer, and that could have different results.
> True. But this is not right outer join, its a left outer join...:)
>
> Postgres should understand that left outer join does not constrict join
> order...

But it can. If your condition was a joining between the other table
and the right side of the left outer join, you'd have the same condition
as a right outer join and the left side. The real condition I think
is that you can join a non-explicitly joined table to the <x> side of an
<x> outer join before the outer join but not to the other side.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephan Szabo 2001-09-24 16:09:48 Re: Server crash caused by CHECK on child
Previous Message Hannu Krosing 2001-09-24 15:26:37 Re: Changing data types

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-09-24 16:09:48 Re: Server crash caused by CHECK on child
Previous Message Josh Berkus 2001-09-24 15:11:59 Re: Bug?: Update on ancestor for a row of a child