From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Greg Stark <gsstark@mit.edu>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Correia, Carla <Carla.Correia@logicacmg.com>
Cc: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Re: Complex outer joins?
Date: Wed, 26 Mar 2003 21:36:09 -0800 (PST)
Message-ID: <20030326212439.J70893-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <878yv1l981.fsf@stark.dyndns.tv>
On 26 Mar 2003, Greg Stark wrote:
> Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
>
> > On Wed, 26 Mar 2003, Tom Lane wrote:
> >
> > > from (G left join L on (G.SELID = L.SELID))
> > > right join C on (L.SELID = C.SELID)
> > >
> > > versus
> > >
> > > from G left join
> > > (L right join C on (L.SELID = C.SELID))
> > > on (G.SELID = L.SELID)
> >
> > I'd noticed that too, but I was trying to do it without changing the
> > type of join since I wasn't sure whether he'd meant one using only left
> > joins or outer joins in general.
>
> Yeah, that's not a particularly enlightening case because if you convert the
> right joins to left joins you see that these aren't actually similar queries
> at all.
>
> the first is
> "C left join (G left join L)"
> and the second is
> "G left join (C left join L)"
>
> They only look similar superficially when written using right joins but
> they're actually totally different structures.
Right, but it would have been an issue in converting to sql form if you
had a set of conditions like C.a=L.a(+) and G.a=L.a(+) except that from
testing that appears to be invalid, so you can't get into the question of
which plan is correct.
> The other example using IS NULL on a column produced by the outer join is more
> fundamental. I'll have to ponder that one. I don't remember how Oracle behaved
> with cases like that because I rarely used that idiom. I think I rarely used
> it because I found it too confusing with Oracle's (*) syntax which I suppose
> begs the question.
You probably can't easily do IS NULL with the oracle syntax, but coalesce,
case or non-strict user defined functions appear to have a similar effect
(and at least in the coalesce case not rejected and give one of the two
expected outputs).
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, gsstark@mit.edu, tgl@sss.pgh.pa.us, Carla.Correia@logicacmg.com
Subject: Re: Complex outer joins?
In-Reply-To: <20030326212439.J70893-100000@megazone23.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox