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 


 

 

 


 

 

 

 

Built-in functions and the CBO

Oracle created function-based indexes (FBI’s) to ensure that indexes are used when you must include a built-in function on an indexed column in your SQL.  For example, the following query would not be able to use an index on the mydate column:

    . . . where to_char(mydate) = ’10-1-07’

If it’s necessary to change an indexed column with a function, you can create a function-based index on the column:

   create index
    mydate_to_char
    on
       mytab (to_char(mydate));

It’s always a good idea to re-work your SQL to remove built-in function from any where clause predicates:

Bad:

   where to_num(char_column) = 123

   where to_char(date_column) = ’10-1-07’

Good:

   where char_column = ‘123’

   where date_column = to_date(’10-1-07’);

The “index invalidation also extends to partitioned table where you use a built-in function on a partitioned table key.

Partition pruning and predicate functions

Partitioning pruning refers to the ability of the cost-based optimizer to exclude irrelevant table partitions when servicing an SQL query.  This blogger has published some excellent advice on the issue of using built-in functions on partition key columns. Essentially, the use of a “predicate” built-in function (e.g. trunc, substr, to_char, &c), will disable partition pruning unless a check constraint is placed on the column:

“When you place a predicate on a function of a partition key column then the optimizer is prevented from pruning unless there is a check constraint to indicate logical equivalence between the column and the function of the column.”

“The partitioning scheme acts effectively as a series of check constraints on the individual partitions that allow table access to be avoided when it can be deduced that a predicate does not resolve to any partitions at all.”

This comment by Pete S. confirms that built-in functions can be problematic when used on table partition keys:

“Elsewhere, this week he has made an interesting observation on the use of functions on partition keys in queries . . . TRUNC prevents the use of partition elimination and therefore negates a major performance enhancing feature in an Oracle DW.”

Also, see these insightful notes on predicate pushing.

The moral of this story is that you should avoid the use of built-in functions on partitioned table keys whenever possible, but if you must use a function predicate on a partition key, make sure to create a corresponding check constraint.

 
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.

 

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