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

 
 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  

Don Burleson Blog 


 

 

 


 

 

 
 

Oracle SQL Profiles

Expert Oracle Tips by Burleson Consulting

March 28, 2013

 

Automatic SQL Tuning

The Oracle SQL optimizer has always been a key component of execution (explain) plan management.  The optimizer was charged with the responsibility of making decisions about execution plans.  However, the optimizer has not always been given sufficient time to gather the information necessary for the best possible decision.  Automatic SQL tuning and SQL Profiles have made this process easier for the optimizer.

The evolution of the internal aids to the optimizer, including SQL Profiles, is as follows:

  • Stored Outlines:  Also called Optimizer Plan Stability, stored outlines were cumbersome to manage.  Additionally it was difficult to swap out execution plans when using plan stability.
  • SQL Profiles - A SQL Profile is a bundle of improved optimizer statistics that is stored in the data dictionary.  SQL Profiles are create by running Automatic SQL Tuning.  The SQL Profile approach first appeared in Oracle 10g.  Allowed to run in tuning mode, the optimizer can gather additional information for making tuning recommendations on specific SQL statements.  Tuning mode also allows the optimizer to recommend the gathering of statistics on objects with stale or missing statistics.  These additional statistics are stored in an SQL Profile.  A SQL tuning Set (STS) could be tested as a workload, and Oracle would allow the DBA to implement changes to execution plans. 
  • SQL Plan management - Starting in 11g, there is an even easier to use approach to locking-down SQL execution plans.  The 10g SQL Profile approach is deprecated, and uses only two parameters, optimizer_capture_sql_plan_baselines and optimizer_use_sql_plan_baselines.  Also see dba_sql_plan_baselines tips.

SQL Profiles

Alluded to above, the automatic tuning advisor allowed the implementation of tuning suggestions in the form of SQL profiles (enhanced CBO statistics, stored in the data dictionary) that will improve performance.  SQL profiles can be used the same way as their historic counterparts, stored outlines.  However, the SQL Profile is easier to use and manage with the help of the automatic tuning advisor. 

Simply put, the SQL Profile is a collection of historical information from prior runs of the SQL statement.  The SQL Profile can contain comparison details of the actual and estimated cardinality and predicate selectivity, etc. A SQL Profile is stored persistently in the data dictionary, so it does not require any application code changes.

In comparison to normal optimization, a SQL profile helps generate a better execution plan  because it is tested against a real-world workload in the SQL Tuning Set (STS).  The SQL statement is thoroughly profiled with the aid of additional tasks like checking for advanced predicate selectivity, correlation between columns, join skews, and complex predicates such as functions. Once a SQL statement is profiled and stored, differing execution plans can be invoked at will.

The optimizer may also be able to improve performance by altering session specific parameters such as the optimizer_mode.  The SQL Profile stores the information on possible improvements.  The information in the SQL Profile, if accepted, is available to the optimizer when running in normal rather than tuning mode.  Where stored outlines fixed the execution plan, a SQL Profile can continue to be beneficial as the contents of the table change.  Thus, it is not necessary or preferred to update SQL Profiles as long as they are beneficial.

Swapping SQL Profiles

While it may not be necessary to swap SQL Profiles as often as it was necessary to swap stored outlines, there are times when it becomes desirable.  The concept of  swapping SQL profiles  is fairly simple.

A SQL profile that specifies the SQL statement is defined for the statement to be tuned.  The new SQL Profile includes an alternative execution plan, in the form of hints.  When this SQL is executed and hits the library cache, Oracle detects that a SQL profile exists for this statement, and automatically applies the hints to change the execution plan.

This approach allows SQL statements to be tuned without ever having to touch the SQL statement itself.  To do this, we use the DBMS_SQLTUNE package which has an import_sql_profile procedure which allows you to swap hints from one SQL profile into another SQL profile.

dbms_sqltune.import_sql_profile(
   sql_text => 'select * from emp',
   profile => sqlprof_attr('ALL_ROWS','IGNORE_OPTIM_EMBEDDED_HINTS')
   category => 'DEFAULT',
   name => 'change_emp',
   force_match => &&6
);

To see how you can swap-out SQL profiles, examine the dbms_sqltune package and the import_sql_profile procedure.

Although SQL Profiles have been an improvement over stored outlines, execution plan management in 11g goes further to help lock down critical SQL execution plans, and tests execution timings before implementing changes.

 
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.

 

 

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

All rights reserved by Burleson

Oracle ? is the registered trademark of Oracle Corporation.


 

��
 
 
 
 

 
 
 

 
Oracle performance tuning software 
 
oracle dba poster
Oracle Linux poster