Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 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 


 

 

 


 

 

 
 

ordered hint Tips

Oracle Tips by Burleson Consulting

July 15, 2013
 

 

 
Oracle provides several methods for reducing the time spent parsing Oracle SQL statements, which can cause a drag on performance when executing complex queries with a large number of possible execution plans. Letís briefly examine some of these methods.

Hinting around with the ordered hint

Oracle must spend a great deal of time parsing multiple table joins to determine the optimal order to join the tables. SQL statements with table joins involving seven or more tables can sometimes take more than 30 minutes to parse because Oracle must evaluate all possible table join orders. This can add up to more than 40,000 orders with only eight tables. The ordered hint is commonly used in conjunction with other hints to suggest a proper join order.

The ordered hint requests that the tables listed in the FROM clause of a SQL statement be joined in the order specified, with the first table in the FROM clause specifying the driving table. The driving table should be the table that returns the smallest number of rows. Using the ordered hint will bypass the very expensive and time-consuming parsing operation and speed the execution of Oracle SQL.

In Listing A is an example of a complex query that is forced to perform a nested loop join with a parallel query on the emp table. Note that Iíve used the ordered hint to direct Oracle to evaluate the tables in the order they are presented in the WHERE clause.

Listing A:

select /*+ ordered use_nl(bonus) parallel(e, 4) */
   e.ename,
   hiredate,
   b.comm
 from
   emp e,
   bonus b
 where
   e.ename = b.ename
 ;


Using the ordered_predicates hint

The ordered_predicates hint is specified in the WHERE clause of a query and is used to specify the order in which Boolean predicates should be evaluated. In the absence of ordered_predicates, Oracle uses the following steps to evaluate the order of SQL predicates:

  1. Subqueries are evaluated before the outer Boolean conditions in the WHERE clause.
  2. All Boolean conditions without built-in functions or subqueries are evaluated in reverse from the order they are found in the WHERE clause, with the last predicate being evaluated first.
  3. Boolean predicates with built-in functions of each predicate are evaluated in increasing order of their estimated evaluation costs.

You can override these default evaluation rules using the ordered_predicates hint, and your WHERE clause items will then be evaluated in the order that they appear in the query. The ordered_predicates hint is commonly used in cases where a PL/SQL function is used in the WHERE clause of a query. It is also very useful in cases where you know the most restrictive predicates and you want Oracle to evaluate these first.


Usage note:

You cannot use the ordered_predicates hint to preserve the order of predicate evaluation on index keys.



Limit the number of table join evaluations

One final way you can improve the performance of SQL parsing is to override Oracleís parameter that controls the number of possible joins evaluated by the cost-based optimizer when evaluating a query. The optimizer_search_limit parameter specifies the maximum number of table join combinations that will be evaluated when Oracle tries to decide the best way to join multiple tables. This parameter helps prevent the optimizer from spending more time evaluating every possible join ordering than could be saved by finding the optimal join order. The optimizer_search_limit parameter also controls the threshold for invoking a star join hint, and a star hint will be honored when the number of tables in the query is less than the optimizer_search_limit. The default value is 5.

These are just a few of the tricks that Oracle DBAs use to optimize the performance of SQL queries in an Oracle database application.

 
 
Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.



 

 

 

 

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 -  2014

All rights reserved by Burleson

Oracle © is the registered trademark of Oracle Corporation.