Oracle SQL Plan Migration Runbook
Objective
This runbook explains how to move a good execution plan from a source environment (Source Environment) to a Production environment using:
- SQL Tuning Set (STS)
- Data Pump (expdp/impdp)
- SQL Plan Management (SPM)
This approach is commonly used by Oracle Apps DBAs during:
- SQL Plan Regression
- Month-End Performance Issues
- Concurrent Program Slow Performance
- Optimizer Plan Changes after Statistics Gathering
- Oracle EBS 12.2 Performance Stabilization
High-Level Flow
Source Environment Steps (Source Environment)
Step 1: Identify the Good SQL Plan
Find the SQL_ID and PLAN_HASH_VALUE of the good plan.
OR
Step 2: Create Empty SQL Tuning Set (STS)
Step 3: Load SQL Information into STS
Step 4: Verify SQL Tuning Set Contents
Formatting commands:
Query STS contents:
Detailed verification:
Step 5: Create Staging Table
Note: Table names and parameters are case-sensitive.
Step 6: Pack STS into Staging Table
Step 7: Create Oracle Directory Object
Step 8: Export Staging Table using Data Pump
Step 9: Transfer Dump File to Production
Transfer the dump file using:
- SCP
- FTP
- SFTP
Example:
Target Environment Steps (Production)
Step 10: Import the Dump File
Step 11: Unpack SQL Tuning Set
Step 12: Load Plan from STS into SQL Plan Baseline
Step 13: Purge Existing SQL from Shared Pool
This forces Oracle to re-parse and pick the new SQL Plan Baseline.
Generate purge command:
Execute generated command:
Step 14: Alternative Method - Load from Cursor Cache
Validation Queries
Check SQL Baselines
Verify Active Plan
Check if Baseline is Used
Oracle Apps DBA Production Checklist
| Check | Status |
|---|---|
| Good SQL_ID identified | ☐ |
| Correct PLAN_HASH_VALUE captured | ☐ |
| STS created successfully | ☐ |
| SQL loaded into STS | ☐ |
| Staging table created | ☐ |
| STS packed successfully | ☐ |
| Data Pump export completed | ☐ |
| Dump transferred securely | ☐ |
| Import completed in Production | ☐ |
| STS unpacked successfully | ☐ |
| SQL Plan Baseline loaded | ☐ |
| Old cursor purged | ☐ |
| Concurrent request rerun | ☐ |
| Improved performance validated | ☐ |
Real-Time Oracle EBS Scenario
Problem
A month-end concurrent request that normally completes in 2 minutes suddenly started taking 4 hours after statistics gathering.
Root Cause
Optimizer selected a new bad execution plan with:
- Full Table Scan
- High Logical Reads
- Excessive Nested Loop Operations
- Large TEMP Usage
Solution
DBA identified a good historical plan from Source Environment and migrated it to Production using:
- SQL Tuning Set (STS)
- SQL Plan Baseline (SPM)
Result
| Before | After |
| Runtime: 4 Hours | Runtime: 2 Minutes |
| TEMP Spike | Stable TEMP |
| CPU High | CPU Normal |
| Business Delay | Business Success |
Important Notes
Best Practices
- Always validate the plan in lower environments first.
- Never purge shared pool aggressively in peak production hours.
- Take business approval before rerunning concurrent requests.
- Verify plan stability after stats gathering.
- Monitor AWR and ASH after implementation.
Important DBA Views
| View | Purpose |
| V$SQL | Active SQL details |
| V$SQLAREA | Aggregated SQL statistics |
| DBA_SQLSET | SQL Tuning Sets |
| DBA_SQL_PLAN_BASELINES | SQL Baselines |
| V$SQL_MONITOR | Real-time SQL monitoring |
| DBA_HIST_SQLSTAT | Historical SQL statistics |
| DBA_HIST_ACTIVE_SESS_HISTORY | ASH performance analysis |
Conclusion
Using SQL Plan Management (SPM) and SQL Tuning Sets (STS) is one of the safest methods to stabilize SQL performance in Oracle EBS 12.2 Production environments.
This approach helps Oracle Apps DBAs:
- Avoid risky code changes
- Restore performance quickly
- Reduce month-end failures
- Stabilize execution plans
- Improve business confidence
It is a critical real-world DBA skill for handling production SQL regressions.
No comments:
Post a Comment