Re: Complex outer joins? - Mailing list pgsql-sql

From Greg Stark
Subject Re: Complex outer joins?
Date
Msg-id 87smtakxes.fsf@stark.dyndns.tv
Whole thread Raw
In response to Re: Complex outer joins?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Complex outer joins?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-sql
Tom Lane <tgl@sss.pgh.pa.us> writes:

> The SQL-standard way of writing this would presumably be either
> 
>     from G left join L on (G.SELID = L.SELID)
>          left join C on (L.SELID = C.SELID and L.SELLEVEL = C.SELLEVEL)

I would think of it as this one.

>     from G left join
>          (L left join C on (L.SELID = C.SELID and L.SELLEVEL = C.SELLEVEL))
>          on (G.SELID = L.SELID)

I don't see how that would be at all different.

> depending on which join you think ought to be done first.  It might be
> that the results are the same in this case, but I'm not convinced of
> that.  In general the results of outer joins definitely depend on join
> order.

I'm pretty sure Oracle actually builds an abstract join representation where
the two queries above would actually be represented the same way. Then decides
the order from amongst the equivalent choices based on performance decisions.

Can you show an example where the join order would affect the result set? I
can't think of any.


-- 
greg



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: How to show timestamp with milliseconds(3 digits) in Select clause in Ver7.1 ?
Next
From: Stephan Szabo
Date:
Subject: Re: Complex outer joins?