How to Use SQL Plan Management (SPM) - Plan Stability Worked Example
(Doc ID 456518.1)
Last updated on OCTOBER 24, 2019
Applies to:Oracle Database - Enterprise Edition - Version 220.127.116.11 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.
SQL Plan management (SPM) is a preventative mechanism that records and evaluates the execution plans of SQL statements over time. SPM builds SQL plan baselines composed of a set of existing plans that are known to be efficient. The SQL plan baselines are then used to preserve performance of corresponding SQL statements, regardless of changes occurring in the system, providing "plan stability".
Common usage scenarios where SQL plan management can improve or preserve SQL performance include:
- Database Upgrade
A database upgrade that installs a new optimizer version usually results in plan changes for a small percentage of SQL statements, with most of the plan changes resulting in either no performance change or improvement. However, certain plan changes may cause performance regressions. The use of SQL plan baselines significantly minimizes potential performance regressions resulting from a database upgrade.
- System/Data Changes
Ongoing system and data changes can impact plans for some SQL statements, potentially causing performance regressions. The use of SQL plan baselines will help to minimize performance regressions and stabilize SQL performance.
- Application upgrade
Deployment of new application modules means introducing new SQL statements into the system. Application software may use appropriate SQL execution plans developed under a standard test configuration for the new SQL statements. If your system configuration is significantly different from the test configuration, the SQL plan baselines can be evolved over time to produce better performance.
If you have a good plan in the cursor cache, then you can load these into SPM so that you can use this baseline to preserve the performance. The following example command illustrates this:
var n number
:n:=dbms_spm.load_plans_from_cursor_cache(sql_id=>'&sql_id', plan_hash_value=>&plan_hash_value, fixed =>'NO', enabled=>'YES');
EXEC dbms_output.put_line('Number of plans loaded: ' || :n);
After enabling the SPM, for those SQL ID's that have SQL plan management baselines, the database will not collect new access plans (even after SPM is disabled - assuming the baseline is active)
The purpose of this Document is to show an example of SQL PLAN MANAGEMENT.
<Document 1309799.1> How to Accept & Unaccept the plans in sql baselines in 18.104.22.168
To view full details, sign in with your My Oracle Support account.
Don't have a My Oracle Support account? Click to get started!