Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Outer Joins are Evil?

Re: Outer Joins are Evil?

From: Stephane Faroult <sfaroult_at_roughsea.com>
Date: Tue, 31 Aug 2004 17:48:54 +0200
Message-Id: <200408311548.i7VFmsNR000775@webmail.nexlink.net>

 

The reasons given for this seem to be -
1. Simplifies user navigation of the structures - i.e. avoids outer joins.
2. Outer joins are slow and should be avoided at all costs. 3. If an FK is missing it is populated with a default value which will relate to an actual row in the target table, hence no rows will ever be dropped - again, supposedly this is to simply SQL and avoid outer joins.

For many cases (I am very tempted to say 'most', but I am sure I would be inundated with counter-examples), outer-joins are not worse than regular (inner) joins. Consider this one :

  select
  from T1, T2
  where T1.C1 = <some value>

       and T1.C2 = T2.C2 (+)

Assume that T2 is indexed on C2. For a regular join, let's say that the optimizer decides to use a nested loop with T1 as the driving table, for eachrow which satisfies the condition on C1 it will use the value of C2 to join on T2.
In a regular join, you search the index, if you find the key then you access the ad hoc block from T2 and return the data. If you don't find it end of thestory. With the outer join, if you don't find it the column in the index, you can return the data even faster than in the case of the inner join with amatch, since you have no table access.

The main worry I have with outer joins is that I'd rather have more outer joins than Oracle allows me too ...

HTH, Stephane Faroult



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--

Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
Received on Tue Aug 31 2004 - 10:39:28 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US