Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

   

Linda Webb

Got breaking Oracle news?    Burleson Consulting Oracle News

Click here for more Oracle News Headlines

 


Tips for How Oracle Chooses between an Index and a Sort

Don Burleson recently addressed a question on the Oracle Forum about how the Oracle optimizer chooses between performing a sort vs. using an index to deliver ordered results with an ORDER BY clause in the SQL: 

http://dbaforums.org/oracle/index.php?showtopic=810

 

He notes:

 

Oracle will always use the cheapest method for sequence an SQL result set and the CBO will use an index if it consumes fewer resources than a sort.  Remember, a sort that cannot fit into RAM will have to be done in the TEMP tablespace, very slow with lots of disk I/O.

 

You "could" use an /*+ index */ hint to force index sequencing, but folks rarely do.

The choice depends on several factors:
 

0 CBO optimizer_mode parameter The all_rows optimizer mode favors non-index sorting while first_rows favors index access and retrieval in index order

 

1 The cpu_cost parameter favors indexes, the io_cost setting favors sorting


2 - The size of your sort_area_size (or pga_aggregate_target, if used)

3 - The clustering_factor of the index (see dba_indexes view)

4 - The db_block_size and avg_row_len

5 - The estimated size of the sorted result set

 

6 The quality of your optimizer statistics, as computed by the dbms_stats package

 

7 The quality of CBO histograms for estimating the size of the final result set
 
Tip! In some cases Oracle is able to bypass a sort by reading the data in sorted order from the index. Oracle will even read data in reverse order from an index to avoid an in-memory sort.

 

 
��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational