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: USE_NL with or without ORDERED

Re: USE_NL with or without ORDERED

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Sat, 15 Sep 2001 02:10:51 -0700
Message-ID: <F001.0038FA2E.20010915021018@fatcity.com>

Larry's answer is totally correct -

The SQL reads:

    select /*+ use_nl(t2) *./

            etc
    from t1,t2
    where t1.id = t2.id

        etc

But manages to hash from T1 to T2.

(I had to play around a little bit to
make the tables and rows the right
size for this to happen).

Looking at the 10053 trace, I got the lines: (with lots of cuts and editing)

General Join Order:
Join Order 1 T1 -> T2

        use_nl    
            calculations - cost = 92
        NO LINES for sort/merge
        NO LINES for hash join
            so the hint IS constraining Oracle to 
            consider only NL when joining T2.

Join Order 2  T2  ->  T1
        Use_nl
            calculations - cost = 127
        sort/merge
            calculations - cost =  64
        hash join
            calculations - cost = 47
                    (sides swapped)

So Oracle arrives at the best path by
considering the join order T2 -> T1,
which makes the hint ignorable, but
then swaps the table order at execution
time, to produce the apparent contradiction.

Jonathan Lewis
http://www.jlcomp.demon.co.uk

Host to The Co-Operative Oracle Users' FAQ http://www.jlcomp.demon.co.uk/faq/ind_faq.html

Author of:
Practical Oracle 8i: Building Efficient Databases

Screen saver or Life saver: http://www.ud.com Use spare CPU to assist in cancer research.

-----Original Message-----
To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> Date: 14 September 2001 10:37

|
|thanks for the explanation. I'm interesting in seeing your answer.
|It seems Oracle should rename USE_NL into USE_NL_or_HASH :-)
|

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jonathan Lewis
  INET: jonathan_at_jlcomp.demon.co.uk

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Sat Sep 15 2001 - 04:10:51 CDT

Original text of this message

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