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 News

 Oracle Forum
 Class Catalog


 Our Staff
 Our Prices
 Help Wanted!

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 UNIX
 Oracle UNIX
 Linux
 Oracle Linux
 Monitoring
 Remote help

 Remote plans
 Remote
services
 Oracle C++
 Oracle Java
 Apache
 JDeveloper
 App Server

 Applications
 Oracle Forms
 Oracle Portal
 11i Upgrades
 SQL Server
 Oracle Concepts
 HTML-DB Tips
 Software Help

 Remote Help  
 Development  

 Implementation


 Financials Training
 Oracle 11i
 Oracle Apps 11i
 Oracle Workflow
 Oracle AR 11i Class
 Oracle AP 11i class
 Oracle GL 11i class
 Oracle HR 11i class
 Oracle FA 11i class
 11i Project Mgt
 11i procurement
 11i collections


 Oracle Posters
 Oracle Books

 Oracle Tuning Book
 Oracle RAC Book
 Oracle Security
 Easy Oracle Books
 Oracle Scripts
 SQL Server DBA
 SQL Design Patterns
 WISE
 Excel-DB   


 BC Oracle News


 Rednecks!
 Dress code
 Arabian Stallion

 Burleson Arabians
 Guide Horses
 Don Burleson Blog
 Golf & Travel


 Privacy Policy
 

 

 
 

11g adaptive cursor sharing tips

Oracle Tips by Burleson Consulting
February 19, 2008

 

Question:  I understand that Oracle11g now has an improved method for cursor_sharing, so that Oracle will compare execution plans, and only use a changed plan when the histogram indicates a difference that makes a difference.  What are the internal details of this 11g adaptive cursor sharing?

Answer:  Oracle has improved cursor_sharing several times over the years.  Remember, adaptive cursor sharing is only deployed in rare cases where a skewed column distribution (as noted by the histogram), indicates that a different execution plan would be faster.  For example, a query with a popular bind variable value would be best served with a full table scan while an unpopular bind variable value would benefit from an index access plan.

But remember, this is a rare occurrence in many systems.

In my experience at BC, about 80% of shops have uniformly distributed data. Large tables remain large, and the distribution of values within a column remain unchanged.

On the other hand, we have roughly 20% of databases that experience highly volatile data loads, where tables are small on one day and huge the next, or cases where the is a "difference that makes a difference". In these databases, huge changes in the tables data (usually associated with high DML) changes the distribution of data values, necessitating a re-analysis of column histograms.

 

Histograms are critical to the CBO decision to choose an index vs. a full scan, and also for determining the optimal table join order.

 

 

Cursor_sharing=similar

 

The original mechanism (cursor_sharing=similar) had significant issues in Oracle9i.  Robert Freeman notes:

"Oracle8i introduced a feature called cursor sharing which provided the ability of the optimizer to convert literals within SQL statements into bind variables in certain situations. As a result, SQL statements that are alike with the exception of literal values, can share a given cursor.

This has the impact of reducing the overall time to parse the SQL statement and, perhaps most importantly, reducing fragmentation of the shared SQL area of the shared pool. Unfortunately, one of the end results of cursor sharing and the use of bind variables is that the optimizer has a difficult time determining the selectivity of the data in the columns associated with the bind variable. This can lead to sub-optimal execution plans. You use the parameter cursor_sharing=force to enable cursor sharing.

Oracle9i now adds modifications to cursor sharing. If you set cursor_sharing=similar, the optimizer will be able to analyze the distribution of the data in the columns (using the analyzed statistics of the table, columns, associated indexes and any histograms that you may have generated, and determine if the parsed execution plan will be optimal. If the plan does appear to be optimal then the parsed SQL statement will be used."

Dr. Tim Hall notes that the 11g adaptive cursor sharing uses bind variable peeking in a different way:

"DBAs are always encouraging developers to use bind variables, but when bind variables are used against columns containing skewed data they sometimes lead to less than optimum execution plans.

This is because the optimizer peaks at the bind variable value during the hard parse of the statement, so the value of a bind variable when the statement is first presented to the server can affect every execution of the statement, regardless of the bind variable values.

Oracle 11g uses Adaptive Cursor Sharing to solve this problem by allowing the server to compare the effectiveness of execution plans between executions with different bind variable values.

If it notices suboptimal plans, it allows certain bind variable values, or ranges of values, to use alternate execution plans for the same statement. This functionality requires no additional configuration."

Dr. Hall also notes that the v$sql keeps this adaptive information:

"If we look at the V$SQL view entry for this query, we can see the IS_BIND_SENSITIVE column is marked as 'Y', so Oracle is aware this query may require differing execution plans depending on the bind variable values, but currently the IS_BIND_AWARE column is marked as 'N', so Oracle as not acted on this yet."
 

SELECT sql_id, child_number, is_bind_sensitive, is_bind_aware
FROM   v$sql
WHERE  sql_text = 'SELECT MAX(id) 
FROM acs_test_tab WHERE record_type = :l_record_type';

SQL_ID        CHILD_NUMBER I I
------------- ------------ - -
9bmm6cmwa8saf            0 Y N

See my relates notes and articles on Oracle cursor sharing and bind variable peeking:

If you like Oracle tuning, you might enjoy my book "Oracle Tuning: The Definitive Reference", with 950 pages of tuning tips and scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.


    Need an Oracle Health Check?
  • Do you have bad performance after an upgrade?
     
  • Need to certify that your database follows best practices?

BC Oracle performance gurus can quickly certify every aspect of your Oracle database and provide a complete verification that your database is fully optimized.

 

 

 

 
 
 

Oracle performance tuning book

 

 

Oracle performance tuning software

 
Oracle performance tuning software
 
SearchOracle web site
 
Oracle performance Tuning 10g reference poster
 
Oracle performance tuning webcast
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

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


 

Copyright © 1996 -  2007 by Burleson Enterprises, Inc. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation.


Hit Counter