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

Free Oracle Tips

HTML Text

 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   


 

 

 


 

 

 

 

 

Oracle WHERE clause

Oracle Tips by Burleson Consulting

 

About Oracle WHERE clause

One of the most common Oracle SQL tuning problems are full-table scans that are imposed by invalidating a WHERE clause predicate with an Oracle built-in Function (BIF). This problem is especially prevalent when constraining SQL queries for date ranges because of the intrinsic encryption of the relational database DATE datatype.

Here are details on using function based indexes.

For example, these WHERE clause predicates might invoke an unexpected full-table scan:

WHERE trunc(ship_date) > trunc(sysdate-7);

WHERE to_char(ship_date,’YYYY-MM-DD’) = ‘2004-01-04’;

SQL WHERE clause order can be important to performance!

Many people believe that the Oracle cost-based SQL optimizer does not consider the order that the Boolean predicates appear in the WHERE clause.

However, there is some evidence that this is not complete true, as evidenced by the order_predicates SQL 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:

  • Subqueries are evaluated before the outer Boolean conditions in the WHERE clause.
  • 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.
  • Boolean predicates with built-in functions of each predicate are evaluated in increasing order of their estimated evaluation costs.

Why is searching for large-table full-table scans critical to SQL tuning?

If the optimizer gets confused or cannot find an appropriate index that matches the WHERE clause, the optimizer will read every row in the table. Hence large-table full-table scans often indicate a missing index or a sub-optimal choice of optimizer goal.

What is the relationship between indexes and SQL performance?

The sole purpose of indexes is to make SQL queries run faster. If the optimizer detects an indexes that matches part of the WHERE clause of the query, then the optimizer will use the index to avoid having to read every row in the table.

Oracle always interrogates the WHERE clause of the SQL statement to see if a matching index exists and then evaluates the cost to see of the index is the lowest-cost access method. By using function-based indexes, the Oracle designer can create a matching index that exactly matches the predicates within the SQL where clause. This ensures that the query is retrieved with a minimal amount of disk I/O and the fastest possible speed. 


 

 

  
 

 
 
 
 
Oracle performance tuning software
 
 

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

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

All rights reserved.

Oracle © is the registered trademark of Oracle Corporation.