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 


 

 

 


 

 

   

Oracle Business Intelligence, OLAP and BI training and consulting tips . . .

Click here for more
Oracle News Headlines

 


Update:  See these later articles on Oracle function-based indexes:

 



Using Function Based Indexes

By Mark Rittman

Using Function-Based Indexes

One of the projects I'm working on now involves tuning an Oracle 8i-based data warehouse, that uses Discoverer as the user query tool. We've been asked to improve the query response time for the warehouse, and one of the first things we picked up on was the fact that most of the user queries resulted in full table scans against the database tables.

For details of enhancements to Function-Based Indexes in Oracle, check out this additional article by Don Burleson. 

Once an FBI is created, you need to create CBO statistics, but beware that there are numerous bugs and issues when analyzing a function-based index.  See these important notes on statistics and function-based indexes.

Having looked at the SQL being produced by Discoverer, the DDL for the various tables, and the explain plans, it became apparent that whilst there were indexes on most of the columns used in the WHERE clauses, the indexes weren't being used because functions were being used on the columns. For example, if a table called EMPLOYEES had an index on the ENAME column and the following query

SELECT name, address, postcode
FROM   employees
WHERE upper(name)='SMITH'

was issued against the table, the index wouldn't get used as the UPPER() function had been applied to it.

In this instance, a new feature called 'Function-Based Indexes' that first appeared with Oracle 8i would help us out. According to this dba-support.com article,

"One of the many new features in Oracle 8i is the Function-Based Index . This allows the DBA to create indexes on functions or expressions; these functions can be user generated pl/sql functions, standard SQL functions (non-aggregate only) or even a C callout.

The function-based index has forced the optimizer to use index range scans (retuning zero or more rowids) on the surname column rather than doing a full table scan (non-index lookup). Optimal performance does vary depending on table size, uniqueness and selectivity of columns, use of fast full table scans etc. Therefore try both methods to gain optimal performance in your database.

It is important to remember that the function-based B*Tree index does not store the expression results in the index but uses an "expression tree". The optimizer performs expression matching by parsing the expression used in the SQL statement and comparing the results against the expression-tree values in the function-based index. This comparison IS case sensitive (ignores spaces) and therefore your function-based index expressions should match expressions used in the SQL statement where clauses. "

In this case, to create the Function-Based Index we need, we'd issue the following DDL;

CREATE INDEX fb_name_idx on employees (UPPER(name));

The article also points out a few prerequistes for working with Function-Based Indexes;

  • After creating the Function-Based Index, you must ANALYZE it

exec dbms_stats.gather_table_stats(
    ownname=>null,
    tabname=> 'EMP',
    estimate_percent=>null,
    cascade=>true,
    method_opt=> ‘FOR ALL HIDDEN COLUMNS SIZE 1′
);

  • You then need to ANALYZE the table

ANALYZE TABLE employees COMPUTE STATISTICS;

  • The users who will use the index need the Execute privilege on the particular function used in the index, if it's a custom function
  • They also need the CREATE INDEX (obviously) and QUERY REWRITE privilege

GRANT CREATE ANY INDEX, QUERY REWRITE TO user;

  • The database needs to have the QUERY_REWRITE_INTEGRITY = TRUSTED, QUERY_REWRITE_ENABLED = TRUE and COMPATIBLE = 8.1.0.0.0 (or higher) parameters set, by using ALTER SYSTEM or amending the init.ora file.
 
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