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

Home -> Community -> Mailing Lists -> Oracle-L -> "order by " clause confuses CBO

"order by " clause confuses CBO

From: Andreas Jung <ajung_at_sz-sb.de>
Date: Wed, 26 Jul 2000 15:35:37 +0200
Message-Id: <10570.113003@fatcity.com>


The following simple join retrieves all rows very quick and the execution plan looks fine.

SQL> select docnum from ojs_main where docnum in (select unique docnum from ojs_de where contains(inhalt,'Tokio or tokyo')>0);

4027 rows selected.

Execution Plan


   0      SELECT STATEMENT Optimizer=HINT: ALL_ROWS (Cost=2183 Card=75          
          18554 Bytes=11488350512)                                              
                                                                                
   1    0   NESTED LOOPS (Cost=2183 Card=7518554 Bytes=11488350512)             
   2    1     TABLE ACCESS (BY GLOBAL INDEX ROWID) OF 'OJS_DE' (Cost=2          
          6 Card=2156 Bytes=3266340)                                            
                                                                                
   3    2       DOMAIN INDEX OF 'OJS_DE_IDX' (Cost=24)                          
   4    1     INDEX (UNIQUE SCAN) OF 'OJS_MAIN_PK' (UNIQUE) (Cost=1 Ca          
          rd=348727 Bytes=4533451)                                              


When I add an "order by" clause Oracle 8i need much more longer than the same query above and the execution is a complete other one. docnum is of type NUMBER and is the primary key in both tables. All tables and indexes are fully analyzied. I also tried to replace the query below by a join over both tables but without any success. I received the same execution plan. Also working with hints did not work. Any idea how to get this query optimized ?

SQL> select docnum from ojs_main where docnum in (select unique docnum from ojs_de where contains(inhalt,'Tokio or tokyo')>0) order by docnum;

4027 rows selected.

Execution Plan


   0      SELECT STATEMENT Optimizer=HINT: ALL_ROWS (Cost=2431 Card=75          
          18554 Bytes=11488350512)                                              
                                                                                
   1    0   MERGE JOIN (Cost=2431 Card=7518554 Bytes=11488350512)               
   2    1     INDEX (FULL SCAN) OF 'OJS_MAIN_PK' (UNIQUE) (Cost=1440 C          
          ard=348727 Bytes=4533451)                                             
                                                                                
   3    1     SORT (JOIN) (Cost=965 Card=2156 Bytes=3266340)                    
   4    3       TABLE ACCESS (BY GLOBAL INDEX ROWID) OF 'OJS_DE' (Cost          
          =26 Card=2156 Bytes=3266340)                                          
                                                                                
   5    4         DOMAIN INDEX OF 'OJS_DE_IDX' (Cost=24 Card=2156)              





-- 
                                _\\|//_
                               (' O-O ')

------------------------------ooO-(_)-Ooo--------------------------------------

   Andreas Jung, Saarbrücker Zeitung Verlag und Druckerei GmbH    Multimedia EU/Saarbrücker Daten-Innovations-Center    Untertürkheimerstraße 15, D-66103 Saarbrücken, Germany    Phone: +49-(0)681-502-1528, Fax: +49-(0)681-502-1509    Email: ajung_at_sz-sb.de (PGP key available)


Received on Wed Jul 26 2000 - 08:35:37 CDT

Original text of this message

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