SlideShare a Scribd company logo
1 of 48
Download to read offline
Adapting and adopting
SQL Plan Management
to achieve execution plan stability for sub-second queries on a high-rate
OLTP mission-critical application
Carlos Sierra
Wide spikes are
usually the
signature of a “plan
flip”
A “plan flip” on one
SQL statement
caused wide spikes
One SQL statement
with 3 distinct
Execution Plans
Plans flip frequently
for this SQL
statement
Multiple plans co-exist
Another SQL
statement with
multiple overlapping
Execution Plans
Motivation
• Plan stability is more valuable than plan flexibility when
• Strict SLAs in the order of milliseconds
• Simple queries execute dozens of times per second
• Out-of-the-box “Automatic SPM Evolve Task” is great … but
• It may accept sub-optimal execution plans on a non-typical application
• e.g.: binds captured could be outdated in a matter of hours
• Historical plan performance could be used to determine future SQL
performance with some degree of confidence
• We just need to implement an autonomous custom algorithm …
About the application and environment
• Oracle 12c multi-tenant on Oracle Servers X5-2 with NVMe SSD
• OLTP application with copies in 30+ databases and 700+ PDBs
• Row by row web-based custom application
• Transaction isolation implemented through application-enforced
serialization
• Few critical queries encapsulated as “critical serial-path transaction”
• Typical transaction executes in ~10ms including up to 10 queries
• A “plan-flip” constantly risks breaching stringent milliseconds SLAs
A typical query
SELECT …
FROM SYSTEMS
WHERE (id, TxnID, 1) IN ( SELECT id, TxnID,
ROW_NUMBER() OVER ( PARTITION BY id ORDER BY
TxnID DESC ) rn
FROM SYSTEMS WHERE TxnID <= :1 )
AND Live = 'Y'
AND ((compartmentId = :2))
ORDER BY compartmentId ASC, id ASC
FETCH FIRST :3 ROWS ONLY
A typical execution plan
A typical performance scorecard
Adaptive SQL Plan Management on 12c
• Refer to this link for details
https://oracle-base.com/articles/12c/adaptive-sql-plan-management-12cr1
• Evolution of SPBs is “on” by default
• View dba_advisor_parameters
• Filter task_name = ‘SYS_AUTO_SPM_EVOLVE_TASK’
• Columns parameter_name and parameter_value
• Look for ACCEPT_PLANS parameter
• Last evolution: DBMS_SPM.report_auto_evolve_task
• Creation of SPB is “off” by default
Automatic SPM Evolve Task
Plan is evaluated using variable
values captured at the time the
test plan is created.
The “evolve task” determines
the base plan performs poorly
when executed passing
outdated values.
This application has a fast
moving time window.
Custom SPM Implementation Objectives
• Reduce the number of incidents where the execution of a new plan
causes a performance regression of an SLA related SQL statement
• Create a SQL Plan Baseline (SPB) a.k.a. “pin a plan” when such a plan
has a proven record of consistent good performance (i.e. learn from
history or lack of history)
• Ignore SQL statements that are too young
• If a SQL statement changes, then re-learn from history and “pin a
plan” once it becomes mature again
• Flag a plan as permanent once its SPB has also matured
• Clean up unwanted plans
FPZ Algorithm
• Pre-select SQL_ID/PHV candidates, mainly from shared pool
• If there exists a valid SQL Plan Baseline (SPB) for candidate
• Demote SPB if underperforms (disable it)
• Promote SPB after proven performance (fix it)
• Else (no SPB exists for candidate)
• Further screen candidate
• Create SPB if candidate is accepted
• Log decision
FPZ Algorithm
Pre-select SQL_ID/PHV candidates
• For PHV, at least one child cursor is valid, shareable and not obsolete
• Parent cursor’s first load time is > 6 days
• SQL (parent cursor) is mature
• Cursor has been active within the last 24 hours
• Parsing user and schema is not SYS nor Oracle managed
• PDB is not CDB$ROOT or PDB$SEED
• PHV and Executions are > 0
• Some others
Consider Plan candidates from AWR, only if
1. Plan is not on Shared Pool
• Plan was generated in the past (AWR) but not currently in memory
2. There are other Plans for SQL on Shared Pool (with no SPB)
• SQL is active and has no SPB
3. Focus is on one SQL and not entire PDB or CDB
• Algorithm skips AWR plans which are candidates from Shared Pool
(because AWR does not store SPB name on SQLSTAT)
Note: not having SPB name on AWR SQLSTAT would cause algorithm to re-
create SPB on every execution
What is a valid SQL Plan Baseline (SPB)?
• Accepted
• Enabled
• Reproduced
• Not necessary Fixed
Disable SPB if underperforms
• Cursor’s average elapsed time per execution > 10x category’s
threshold
• Cursor’s average elapsed time per execution > 100x SPB average
elapsed time per execution
• Evaluate after N executions (as per candidate threshold)
SPB demotion to “DISABLE”
Cursor Cache
Plans with
SPB
SPBs that qualify for a
“DISABLE” demotion
Enabled
Accepted
Reproduced
Not Fixed
Avg ET > 10x Max Category Threshold
Avg ET > 100x SPB snapshot
SPB evaluation and conditional promotion
• If not “fixed” and “created” > 14 days
• Set “FIX” flag to YES
• Plan is mature, in use and with acceptable performance
• Note: after “fixed” no new plans are created into Plan History
SPB promotion to “FIX”
Cursor Cache
Plans with
SPB
SPBs that qualify for a
“FIX” promotion
Enabled
Accepted
Reproduced
Not Fixed
Age > 14d
Further screen SQL_ID/PHV candidates
• Plan has > “X” executions
• > 10,000 for some categories
• > 1,000 for other categories
• Hint: Start SPM Automation with high-rate SQL only
• Plan’s average execution time is < “X”ms
• < 0.5ms for some categories
• < 10ms for other categories
• Proven acceptable “on average” performance based on cumulative metrics
• Or lack of historical metrics which usually denote a light-weight SQL
SPB creation
Cursor Cache and
AWR SQLSTAT
Plan candidates
for SPB
Plans that qualify
for a SPB
Executions > 2,500
Elapsed Time per Execution < 10s
Age > 4d
Executions > 25,000
Elapsed Time per Execution < 1.25ms
Age > 6d
Categorizing SQL statements
• Use Module and Action, and/or parse SQL text
• Critical transaction (e.g.)
• Commit path
• Begin transaction
• Garbage collection
• Non-critical transaction (e.g.)
• Scan read
• Something else (i.e.)
• Categorize as non-application and possibly reject candidate
Further screen SQL_ID/PHV candidates (cont.)
• Plan has no AWR performance history (low database load); or
• Plan has AWR recent performance history (60 days) such as
• Execution time’s 90th Percentile < 2x cursor’s category and < 20x cursor’s avg
• e.g. < 2.5ms and < 20x avg
• Execution time’s 95th Percentile < 3x cursor’s category and < 30x cursor’s avg
• e.g. < 3.75ms and < 30x avg
• Execution time’s 97th Percentile < 4x cursor’s category and < 40x cursor’s avg
• e.g. < 5ms and < 40x avg
• Execution time’s 99th Percentile < 5x cursor’s category and < 50x cursor’s avg
• e.g. < 6.25ms and < 50x avg
Algorithm’s aggressiveness style - sample
Level Meaning > Executions < Elapsed Time (ms)
1 Conservative 25,000 0.25
2 20,000 0.50
3 Moderate 15,000 0.75
4 10,000 1.00
5 Aggressive 5,000 1.25
Lvl > Execs < ET (ms) Avg < ET (ms) 90th Pctl < ET (ms) 95th Pctl < ET (ms) 97th Pctl < ET (ms) 99th Pctl
1 25,000 0.25 0.50 0.75 1.00 1.25
2 20,000 0.50 1.00 1.50 2.00 2.50
3 15,000 0.75 1.50 2.25 3.00 3.75
4 10,000 1.00 2.00 3.00 4.00 5.00
5 5,000 1.25 2.50 3.75 5.00 6.25
Begin Tx Category
Implementation
Sample category thresholds implementation
Category > Executions
Conservative
> Executions
Moderate
> Executions
Aggressive
< ET (ms)
Conservative
< ET (ms)
Moderate
< ET (ms)
Aggressive
CommitTx 25,000 15,000 5,000 0.5 1.5 2.5
BeginTx 25,000 15,000 5,000 0.25 0.75 1.25
Read 5,000 3,000 1,000 10 30 50
GC 5,000 3,000 1,000 1,000 3,000 5,000
Other 5,000 3,000 1,000 200 600 1,000
Create SQL Plan Baseline (SPB)
• Enabled
• Accepted
• But not “Fixed”
• Source most from Cursor Cache, and some from AWR
Log decision
• Update SPB “description”
• Source SQL_ID
• Source plan hash value (PHV)
• Date when promoted to “Fixed” or demoted from “Fixed”
• Write into log
• Created SPB with selection metrics such as execution percentiles
• Promoted and demoted SPBs, with criteria used
• Rejected candidates and reason
• Preserve logs for at least 1 month
FPZ Algorithm (recap)
• Pre-select SQL_ID/PHV candidates, mainly from shared pool
• If there exists a valid SQL Plan Baseline (SPB) for candidate
• Demote SPB if underperforms (disable it)
• Promote SPB after proven performance (fix it)
• Else (no SPB exists for candidate)
• Further screen candidate
• Create SPB if candidate is accepted
• Log decision
AWR Configuration
• EXEC DBMS_SPM.CONFIGURE('plan_retention_weeks', 13);
• EXEC DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(topnsql=>300);
• ALTER SYSTEM SET "_awr_sql_child_limit" = 2000;
Additional considerations
• Set Autopurge to NO for Plans on black-list
• Manually (out of scope for automation)
• What if there is no “proven consistent performance”?
• What if average performance is higher than target threshold?
• What if predicates selectivity requires more than one execution plan?
• What if SQL produces different plans across databases?
FPZ Algorithm Automation
• PL/SQL package
• Can be executed from SQL*Plus or OEM calling a PL/SQL library
• Executed connecting as CDB$ROOT
• Set of configuration constants
• How many SPB to create and how many promote? (or report only)
• Report rejected candidates and non-promoted SPBs?
• Evaluate particular application categories
• Number of executions to consider a candidate, or to qualify for a SPB
• Time per execution to qualify a candidate for SPM
• Factors over average elapsed time for 90th, 95th, 97th and 99th percentiles
• Days of AWR history to consider
Dry run results and sample output
+------------------------------------------------------------
|
| Candidates : 2019
| SPBs Qualified for Creation : 977
| SPBs Qualified for Promotion : 4
| SPBs Created : 0
| SPBs Promoted : 0
| Date and Time (end) : 2017-10-22T14:33:42
| Duration (secs) : 102
|
+------------------------------------------------------------
Implementation results
Implementation results
Implementation results
Outlier sample
Outliers
• SQL not considered by PL/SQL library
• Candidates rejected for valid reasons (performance, executions, age, etc.)
• Bug on Algorithm or PL/SQL library?
• Algorithm too restrictive?
• Short-lived small spikes
• Executions burst combined with frequent hard-parses due to CBO statistics
gathering
• SQL has multiple optimal plans as per Adaptive Cursor Sharing (ACS)
• Algorithm implements a subset
Closing remarks
• Past performance may not be indicative of future results
• Nevertheless: historical plan performance can be used to determine future SQL
performance with some degree of confidence
• Not every SQL statement gets a SPB
• Some queries are still at risk of spikes
• Lower rate of executions, performance above thresholds, new SQL, etc.
• And not every plan becomes a SPB (think ACS)
• Method presented reduces frequency of “plan flips”
• Consistent latency is more important than best performance

More Related Content

What's hot

Oracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsOracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsAnil Nair
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsZohar Elkayam
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTanel Poder
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersCarlos Sierra
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsCarlos Sierra
 
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Carlos Sierra
 
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1SolarWinds
 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slidesMohamed Farouk
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Kyle Hailey
 
Online index rebuild automation
Online index rebuild automationOnline index rebuild automation
Online index rebuild automationCarlos Sierra
 
High Availability for Oracle SE2
High Availability for Oracle SE2High Availability for Oracle SE2
High Availability for Oracle SE2Markus Flechtner
 
Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)Tanel Poder
 
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DBHow a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DBCarlos Sierra
 
Oracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptOracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptChien Chung Shen
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptChien Chung Shen
 

What's hot (20)

Oracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret InternalsOracle RAC 19c: Best Practices and Secret Internals
Oracle RAC 19c: Best Practices and Secret Internals
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
 
SQL Tuning 101
SQL Tuning 101SQL Tuning 101
SQL Tuning 101
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools short
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginners
 
AWR and ASH Deep Dive
AWR and ASH Deep DiveAWR and ASH Deep Dive
AWR and ASH Deep Dive
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
 
SQLd360
SQLd360SQLd360
SQLd360
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
 
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slides
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
 
Online index rebuild automation
Online index rebuild automationOnline index rebuild automation
Online index rebuild automation
 
High Availability for Oracle SE2
High Availability for Oracle SE2High Availability for Oracle SE2
High Availability for Oracle SE2
 
Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)
 
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DBHow a Developer can Troubleshoot a SQL performing poorly on a Production DB
How a Developer can Troubleshoot a SQL performing poorly on a Production DB
 
Oracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptOracle Database Performance Tuning Concept
Oracle Database Performance Tuning Concept
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning Concept
 

Similar to Adapting and adopting spm v04

Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresJitendra Singh
 
OUG Harmony 2012 - Using SQL Plan Baselines for Performance Testing
OUG Harmony 2012 -  Using SQL Plan Baselines for Performance TestingOUG Harmony 2012 -  Using SQL Plan Baselines for Performance Testing
OUG Harmony 2012 - Using SQL Plan Baselines for Performance TestingMaris Elsins
 
An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1Navneet Upneja
 
Optimizing applications and database performance
Optimizing applications and database performanceOptimizing applications and database performance
Optimizing applications and database performanceInam Bukhary
 
Oracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuningOracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuningSmitha Padmanabhan
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerAndrejs Vorobjovs
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDAGEOP LTD
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerMaris Elsins
 
Configuring Sage 500 for Performance
Configuring Sage 500 for PerformanceConfiguring Sage 500 for Performance
Configuring Sage 500 for PerformanceRKLeSolutions
 
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
제3회난공불락 오픈소스 인프라세미나 - MySQL PerformanceTommy Lee
 
ebs-performance-tuning-part-1-470542.pdf
ebs-performance-tuning-part-1-470542.pdfebs-performance-tuning-part-1-470542.pdf
ebs-performance-tuning-part-1-470542.pdfElboulmaniMohamed
 
261197832 8-performance-tuning-part i
261197832 8-performance-tuning-part i261197832 8-performance-tuning-part i
261197832 8-performance-tuning-part iNaviSoft
 
collab2011-tuning-ebusiness-421966.pdf
collab2011-tuning-ebusiness-421966.pdfcollab2011-tuning-ebusiness-421966.pdf
collab2011-tuning-ebusiness-421966.pdfElboulmaniMohamed
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Antonios Chatzipavlis
 
Apache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
Apache Kylin: OLAP Engine on Hadoop - Tech Deep DiveApache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
Apache Kylin: OLAP Engine on Hadoop - Tech Deep DiveXu Jiang
 
Collaborate 2011-tuning-ebusiness-416502
Collaborate 2011-tuning-ebusiness-416502Collaborate 2011-tuning-ebusiness-416502
Collaborate 2011-tuning-ebusiness-416502kaziul Islam Bulbul
 
Performance Management in Oracle 12c
Performance Management in Oracle 12cPerformance Management in Oracle 12c
Performance Management in Oracle 12cAlfredo Krieg
 

Similar to Adapting and adopting spm v04 (20)

Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
sqltuning101-170419021007-2.pdf
sqltuning101-170419021007-2.pdfsqltuning101-170419021007-2.pdf
sqltuning101-170419021007-2.pdf
 
OUG Harmony 2012 - Using SQL Plan Baselines for Performance Testing
OUG Harmony 2012 -  Using SQL Plan Baselines for Performance TestingOUG Harmony 2012 -  Using SQL Plan Baselines for Performance Testing
OUG Harmony 2012 - Using SQL Plan Baselines for Performance Testing
 
An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1
 
Optimizing applications and database performance
Optimizing applications and database performanceOptimizing applications and database performance
Optimizing applications and database performance
 
SQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProceduresSQLDay2013_MarcinSzeliga_StoredProcedures
SQLDay2013_MarcinSzeliga_StoredProcedures
 
Oracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuningOracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuning
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource Manager
 
Database Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance AnalysisDatabase Fundamental Concepts- Series 1 - Performance Analysis
Database Fundamental Concepts- Series 1 - Performance Analysis
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource Manager
 
Configuring Sage 500 for Performance
Configuring Sage 500 for PerformanceConfiguring Sage 500 for Performance
Configuring Sage 500 for Performance
 
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
제3회난공불락 오픈소스 인프라세미나 - MySQL Performance
 
ebs-performance-tuning-part-1-470542.pdf
ebs-performance-tuning-part-1-470542.pdfebs-performance-tuning-part-1-470542.pdf
ebs-performance-tuning-part-1-470542.pdf
 
261197832 8-performance-tuning-part i
261197832 8-performance-tuning-part i261197832 8-performance-tuning-part i
261197832 8-performance-tuning-part i
 
collab2011-tuning-ebusiness-421966.pdf
collab2011-tuning-ebusiness-421966.pdfcollab2011-tuning-ebusiness-421966.pdf
collab2011-tuning-ebusiness-421966.pdf
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
 
Apache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
Apache Kylin: OLAP Engine on Hadoop - Tech Deep DiveApache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
Apache Kylin: OLAP Engine on Hadoop - Tech Deep Dive
 
Collaborate 2011-tuning-ebusiness-416502
Collaborate 2011-tuning-ebusiness-416502Collaborate 2011-tuning-ebusiness-416502
Collaborate 2011-tuning-ebusiness-416502
 
Performance Management in Oracle 12c
Performance Management in Oracle 12cPerformance Management in Oracle 12c
Performance Management in Oracle 12c
 

Recently uploaded

Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Français Patch Tuesday - Avril
Français Patch Tuesday - AvrilFrançais Patch Tuesday - Avril
Français Patch Tuesday - AvrilIvanti
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 

Recently uploaded (20)

Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.
 
Français Patch Tuesday - Avril
Français Patch Tuesday - AvrilFrançais Patch Tuesday - Avril
Français Patch Tuesday - Avril
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 

Adapting and adopting spm v04

  • 1. Adapting and adopting SQL Plan Management to achieve execution plan stability for sub-second queries on a high-rate OLTP mission-critical application Carlos Sierra
  • 2. Wide spikes are usually the signature of a “plan flip”
  • 3. A “plan flip” on one SQL statement caused wide spikes
  • 4. One SQL statement with 3 distinct Execution Plans
  • 5. Plans flip frequently for this SQL statement
  • 6. Multiple plans co-exist Another SQL statement with multiple overlapping Execution Plans
  • 7. Motivation • Plan stability is more valuable than plan flexibility when • Strict SLAs in the order of milliseconds • Simple queries execute dozens of times per second • Out-of-the-box “Automatic SPM Evolve Task” is great … but • It may accept sub-optimal execution plans on a non-typical application • e.g.: binds captured could be outdated in a matter of hours • Historical plan performance could be used to determine future SQL performance with some degree of confidence • We just need to implement an autonomous custom algorithm …
  • 8. About the application and environment • Oracle 12c multi-tenant on Oracle Servers X5-2 with NVMe SSD • OLTP application with copies in 30+ databases and 700+ PDBs • Row by row web-based custom application • Transaction isolation implemented through application-enforced serialization • Few critical queries encapsulated as “critical serial-path transaction” • Typical transaction executes in ~10ms including up to 10 queries • A “plan-flip” constantly risks breaching stringent milliseconds SLAs
  • 9. A typical query SELECT … FROM SYSTEMS WHERE (id, TxnID, 1) IN ( SELECT id, TxnID, ROW_NUMBER() OVER ( PARTITION BY id ORDER BY TxnID DESC ) rn FROM SYSTEMS WHERE TxnID <= :1 ) AND Live = 'Y' AND ((compartmentId = :2)) ORDER BY compartmentId ASC, id ASC FETCH FIRST :3 ROWS ONLY
  • 12. Adaptive SQL Plan Management on 12c • Refer to this link for details https://oracle-base.com/articles/12c/adaptive-sql-plan-management-12cr1 • Evolution of SPBs is “on” by default • View dba_advisor_parameters • Filter task_name = ‘SYS_AUTO_SPM_EVOLVE_TASK’ • Columns parameter_name and parameter_value • Look for ACCEPT_PLANS parameter • Last evolution: DBMS_SPM.report_auto_evolve_task • Creation of SPB is “off” by default
  • 13. Automatic SPM Evolve Task Plan is evaluated using variable values captured at the time the test plan is created. The “evolve task” determines the base plan performs poorly when executed passing outdated values. This application has a fast moving time window.
  • 14. Custom SPM Implementation Objectives • Reduce the number of incidents where the execution of a new plan causes a performance regression of an SLA related SQL statement • Create a SQL Plan Baseline (SPB) a.k.a. “pin a plan” when such a plan has a proven record of consistent good performance (i.e. learn from history or lack of history) • Ignore SQL statements that are too young • If a SQL statement changes, then re-learn from history and “pin a plan” once it becomes mature again • Flag a plan as permanent once its SPB has also matured • Clean up unwanted plans
  • 15. FPZ Algorithm • Pre-select SQL_ID/PHV candidates, mainly from shared pool • If there exists a valid SQL Plan Baseline (SPB) for candidate • Demote SPB if underperforms (disable it) • Promote SPB after proven performance (fix it) • Else (no SPB exists for candidate) • Further screen candidate • Create SPB if candidate is accepted • Log decision
  • 17. Pre-select SQL_ID/PHV candidates • For PHV, at least one child cursor is valid, shareable and not obsolete • Parent cursor’s first load time is > 6 days • SQL (parent cursor) is mature • Cursor has been active within the last 24 hours • Parsing user and schema is not SYS nor Oracle managed • PDB is not CDB$ROOT or PDB$SEED • PHV and Executions are > 0 • Some others
  • 18. Consider Plan candidates from AWR, only if 1. Plan is not on Shared Pool • Plan was generated in the past (AWR) but not currently in memory 2. There are other Plans for SQL on Shared Pool (with no SPB) • SQL is active and has no SPB 3. Focus is on one SQL and not entire PDB or CDB • Algorithm skips AWR plans which are candidates from Shared Pool (because AWR does not store SPB name on SQLSTAT) Note: not having SPB name on AWR SQLSTAT would cause algorithm to re- create SPB on every execution
  • 19. What is a valid SQL Plan Baseline (SPB)? • Accepted • Enabled • Reproduced • Not necessary Fixed
  • 20. Disable SPB if underperforms • Cursor’s average elapsed time per execution > 10x category’s threshold • Cursor’s average elapsed time per execution > 100x SPB average elapsed time per execution • Evaluate after N executions (as per candidate threshold)
  • 21. SPB demotion to “DISABLE” Cursor Cache Plans with SPB SPBs that qualify for a “DISABLE” demotion Enabled Accepted Reproduced Not Fixed Avg ET > 10x Max Category Threshold Avg ET > 100x SPB snapshot
  • 22. SPB evaluation and conditional promotion • If not “fixed” and “created” > 14 days • Set “FIX” flag to YES • Plan is mature, in use and with acceptable performance • Note: after “fixed” no new plans are created into Plan History
  • 23. SPB promotion to “FIX” Cursor Cache Plans with SPB SPBs that qualify for a “FIX” promotion Enabled Accepted Reproduced Not Fixed Age > 14d
  • 24. Further screen SQL_ID/PHV candidates • Plan has > “X” executions • > 10,000 for some categories • > 1,000 for other categories • Hint: Start SPM Automation with high-rate SQL only • Plan’s average execution time is < “X”ms • < 0.5ms for some categories • < 10ms for other categories • Proven acceptable “on average” performance based on cumulative metrics • Or lack of historical metrics which usually denote a light-weight SQL
  • 25. SPB creation Cursor Cache and AWR SQLSTAT Plan candidates for SPB Plans that qualify for a SPB Executions > 2,500 Elapsed Time per Execution < 10s Age > 4d Executions > 25,000 Elapsed Time per Execution < 1.25ms Age > 6d
  • 26. Categorizing SQL statements • Use Module and Action, and/or parse SQL text • Critical transaction (e.g.) • Commit path • Begin transaction • Garbage collection • Non-critical transaction (e.g.) • Scan read • Something else (i.e.) • Categorize as non-application and possibly reject candidate
  • 27.
  • 28. Further screen SQL_ID/PHV candidates (cont.) • Plan has no AWR performance history (low database load); or • Plan has AWR recent performance history (60 days) such as • Execution time’s 90th Percentile < 2x cursor’s category and < 20x cursor’s avg • e.g. < 2.5ms and < 20x avg • Execution time’s 95th Percentile < 3x cursor’s category and < 30x cursor’s avg • e.g. < 3.75ms and < 30x avg • Execution time’s 97th Percentile < 4x cursor’s category and < 40x cursor’s avg • e.g. < 5ms and < 40x avg • Execution time’s 99th Percentile < 5x cursor’s category and < 50x cursor’s avg • e.g. < 6.25ms and < 50x avg
  • 29. Algorithm’s aggressiveness style - sample Level Meaning > Executions < Elapsed Time (ms) 1 Conservative 25,000 0.25 2 20,000 0.50 3 Moderate 15,000 0.75 4 10,000 1.00 5 Aggressive 5,000 1.25 Lvl > Execs < ET (ms) Avg < ET (ms) 90th Pctl < ET (ms) 95th Pctl < ET (ms) 97th Pctl < ET (ms) 99th Pctl 1 25,000 0.25 0.50 0.75 1.00 1.25 2 20,000 0.50 1.00 1.50 2.00 2.50 3 15,000 0.75 1.50 2.25 3.00 3.75 4 10,000 1.00 2.00 3.00 4.00 5.00 5 5,000 1.25 2.50 3.75 5.00 6.25 Begin Tx Category Implementation
  • 30. Sample category thresholds implementation Category > Executions Conservative > Executions Moderate > Executions Aggressive < ET (ms) Conservative < ET (ms) Moderate < ET (ms) Aggressive CommitTx 25,000 15,000 5,000 0.5 1.5 2.5 BeginTx 25,000 15,000 5,000 0.25 0.75 1.25 Read 5,000 3,000 1,000 10 30 50 GC 5,000 3,000 1,000 1,000 3,000 5,000 Other 5,000 3,000 1,000 200 600 1,000
  • 31. Create SQL Plan Baseline (SPB) • Enabled • Accepted • But not “Fixed” • Source most from Cursor Cache, and some from AWR
  • 32. Log decision • Update SPB “description” • Source SQL_ID • Source plan hash value (PHV) • Date when promoted to “Fixed” or demoted from “Fixed” • Write into log • Created SPB with selection metrics such as execution percentiles • Promoted and demoted SPBs, with criteria used • Rejected candidates and reason • Preserve logs for at least 1 month
  • 33. FPZ Algorithm (recap) • Pre-select SQL_ID/PHV candidates, mainly from shared pool • If there exists a valid SQL Plan Baseline (SPB) for candidate • Demote SPB if underperforms (disable it) • Promote SPB after proven performance (fix it) • Else (no SPB exists for candidate) • Further screen candidate • Create SPB if candidate is accepted • Log decision
  • 34. AWR Configuration • EXEC DBMS_SPM.CONFIGURE('plan_retention_weeks', 13); • EXEC DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(topnsql=>300); • ALTER SYSTEM SET "_awr_sql_child_limit" = 2000;
  • 35. Additional considerations • Set Autopurge to NO for Plans on black-list • Manually (out of scope for automation) • What if there is no “proven consistent performance”? • What if average performance is higher than target threshold? • What if predicates selectivity requires more than one execution plan? • What if SQL produces different plans across databases?
  • 36. FPZ Algorithm Automation • PL/SQL package • Can be executed from SQL*Plus or OEM calling a PL/SQL library • Executed connecting as CDB$ROOT • Set of configuration constants • How many SPB to create and how many promote? (or report only) • Report rejected candidates and non-promoted SPBs? • Evaluate particular application categories • Number of executions to consider a candidate, or to qualify for a SPB • Time per execution to qualify a candidate for SPM • Factors over average elapsed time for 90th, 95th, 97th and 99th percentiles • Days of AWR history to consider
  • 37.
  • 38. Dry run results and sample output +------------------------------------------------------------ | | Candidates : 2019 | SPBs Qualified for Creation : 977 | SPBs Qualified for Promotion : 4 | SPBs Created : 0 | SPBs Promoted : 0 | Date and Time (end) : 2017-10-22T14:33:42 | Duration (secs) : 102 | +------------------------------------------------------------
  • 39.
  • 40.
  • 41.
  • 42.
  • 47. Outliers • SQL not considered by PL/SQL library • Candidates rejected for valid reasons (performance, executions, age, etc.) • Bug on Algorithm or PL/SQL library? • Algorithm too restrictive? • Short-lived small spikes • Executions burst combined with frequent hard-parses due to CBO statistics gathering • SQL has multiple optimal plans as per Adaptive Cursor Sharing (ACS) • Algorithm implements a subset
  • 48. Closing remarks • Past performance may not be indicative of future results • Nevertheless: historical plan performance can be used to determine future SQL performance with some degree of confidence • Not every SQL statement gets a SPB • Some queries are still at risk of spikes • Lower rate of executions, performance above thresholds, new SQL, etc. • And not every plan becomes a SPB (think ACS) • Method presented reduces frequency of “plan flips” • Consistent latency is more important than best performance