BC remote Oracle DBA - Call (800) 766-1884  
Oracle Consulting Oracle Training Development

Remote DBA

Remote DBA Plans  

Remote DBA Service

Remote DBA RAC

   
Remote DBA Oracle Home
Remote DBA Oracle Training
Remote DBA SQL Tuning Consulting
Remote DBA Oracle Tuning Consulting
Remote DBA Data Warehouse Consulting
Remote DBA Oracle Project Management
Remote DBA Oracle Security Assessment
Remote DBA Unix Consulting
Burleson Books
Burleson Articles
Burleson Web Courses
Burleson Qualifications
Oracle Links
Remote DBA Oracle Monitoring
Remote DBA Support Benefits
Remote DBA Plans & Prices
Our Automation Strategy
What We Monitor
Oracle Apps Support
Print Our Brochure
Contact Us (e-mail)
Oracle Job Opportunities
Oracle Consulting Prices





   

 

 

 

Remote DBA services

Remote DBA Support

Remote DBA RAC

Remote DBA Reasons

Remote Oracle Tuning

Remote DBA Links

Oracle DBA Support

Oracle DBA Forum

Oracle Disaster

Oracle Training

Oracle Tuning

Oracle Training

 Remote DBA SQL Server

Remote MSSQL Consulting

Oracle DBA Hosting

Oracle License Negotiation

 

 


 

 

 

 

 

 

 

Index Usage for Queries with IN Conditions

Oracle Tips by Burleson Consulting

When a query has an IN condition to evaluate multiple expressions, the SQL optimizer will often perform a full-table scan, but with many variant execution plans. Queries that evaluate multiple conditions can execute with TABLE ACCESS FULL, CONCATENATION, INLIST ITERATOR, and UNION, which all perform the exact same function of returning rows with multiple values.

To illustrate, consider the following simple query.

select
   ename
from
   emp
where
   job IN ('MANAGER','PRESIDENT')
;

Here you see the execution plan. Note the use of the CONCATENATION operator.

OPERATION
--------------------------------------------------------------------------------
OPTIONS                        OBJECT_NAME                      POSITION
------------------------------ ------------------------------ ----------
SELECT STATEMENT
  CONCATENATION
                                                                       1
    TABLE ACCESS
BY INDEX ROWID                 EMP                                     1
      INDEX
RANGE SCAN                     JOB_IDX                                 1
    TABLE ACCESS
BY INDEX ROWID                 EMP                                     2
      INDEX
RANGE SCAN                     JOB_IDX                                 1

Now we change to the CBO by adding a first_rows hint, and we see an entirely different execution plan.

OPERATION
--------------------------------------------------------------------------------
OPTIONS                        OBJECT_NAME                      POSITION
------------------------------ ------------------------------ ----------
SELECT STATEMENT
                                                                       1
  INLIST ITERATOR
                                                                       1
    TABLE ACCESS
BY INDEX ROWID                 EMP                                     1
      INDEX
RANGE SCAN                     JOB_IDX                                 1

Of course, this query can also be rewritten to utilize the union SQL operator. Here is an equivalent query.

select /*+ first_rows */
   ename
from
   emp
where
   job = 'MANAGER'
union
select ename from emp
where
   job = 'PRESIDENT'
;

Here you see the execution plan using the UNION-ALL table access method.

OPERATION
--------------------------------------------------------------------------------
OPTIONS                        OBJECT_NAME                      POSITION
------------------------------ ------------------------------ ----------
SELECT STATEMENT
                                                                       6
  SORT
UNIQUE                                                                 1
    UNION-ALL
                                                                       1
      TABLE ACCESS
BY INDEX ROWID                 EMP                                     1
        INDEX
RANGE SCAN                     JOB_IDX                                 1
      TABLE ACCESS
BY INDEX ROWID                 EMP                                     2
        INDEX
RANGE SCAN                     JOB_IDX                                 1

Here you see three alternative execution plans for the exact same result set. The point is that there are many opportunities to change the execution plan for queries that evaluate for multiple conditions, and in most cases you must actually time the queries to see which execution plan is fastest for your specific query.

Conclusion

This chapter has been concerned with the appropriate use of indexes to service Oracle queries. The main points of this chapter include these:

  • The number of table blocks accessed by a query determines whether to use an index range scan or a full-table scan. You must evaluate the number of blocks returned by each form of the query to determine the fastest execution path.

  • Using BIFs in a query or performing computations on an index column can sometimes invalidate the index and cause a full-table scan.

  • When using the RBO, bitmap and function-based indexes will be ignored.

  • Oracle bitmap indexes have been enhanced to allow for columns that possess up to 1000 distinct values.

  • Oracle provides alternative indexing methods including bitmap indexes, function-based indexes, and reverse-key indexes to provide performance improvements for specialized queries.

Next, let’s move on and look at how to tune queries that maximize performance for Oracle data warehouses.


This is an excerpt from "Oracle High-Performance SQL Tuning" by Donald K. Burleson, published by Oracle Press.


Expert Remote DBA

BC is America's oldest and largest Remote DBA Oracle support provider.  Get real Remote DBA experts, call
BC Remote DBA today.

 

 

Remote DBA Service
 

Oracle Tuning Book

 

Advance SQL Tuning Book 

BC Oracle support

Oracle books by Rampant

Oracle monitoring software

 

 

 

 

 

 

BC Remote Oracle Support

Remote DBA

Remote DBA Services

Copyright © 1996 -  2013 by Burleson. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.



Hit Counter