๐ Objective
This document provides a structured approach to Oracle Database Performance Tuning using real production methodologies followed by senior DBAs and performance engineers.
๐ฏ What is Performance Tuning?
Performance tuning is the process of:
Identifying bottlenecks
Reducing response time
Improving throughput
Optimizing resource utilization
๐ง Core Performance Tuning Philosophy
“Do not tune blindly. Identify the bottleneck first.”
๐️ Oracle Performance Architecture
Performance issues usually come from one of these areas:
| Area | Symptoms |
|---|---|
| CPU | High load, slow SQL |
| Memory | Swapping, cache misses |
| I/O | Slow reads/writes |
| Network | Session delays |
| SQL | High elapsed time |
| Locks | Blocking sessions |
| Configuration | Poor parameter setup |
๐ Performance Tuning Methodology
๐ฅ Standard Workflow
Problem Detection
↓
Collect Metrics
↓
Identify Bottleneck
↓
Analyze Root Cause
↓
Implement Fix
↓
Validate Improvement
๐ 1. Initial Health Check
✅ Database Load
SELECT * FROM v$sysmetric_summary;
✅ Active Sessions
SELECT inst_id, status, COUNT(*)
FROM gv$session
GROUP BY inst_id, status;
✅ Top Wait Events
SELECT event, total_waits, time_waited
FROM v$system_event
ORDER BY time_waited DESC;
⚡ 2. Wait Event Analysis (Most Important)
๐ Oracle Wait Classes
| Wait Event | Meaning |
|---|---|
| db file sequential read | Single block read |
| db file scattered read | Full table scan |
| log file sync | Commit wait |
| enq: TX row lock contention | Locking issue |
| latch free | Contention |
| direct path read/write | Parallel query/temp usage |
๐ง Golden Rule
Tune the highest DB time contributor first.
๐ 3. AWR Report Analysis
Generate AWR
@?/rdbms/admin/awrrpt.sql
๐ Important Sections in AWR
✅ Load Profile
Check:
DB Time
Logical Reads
Physical Reads
✅ Top Foreground Wait Events
Identify:
CPU bottleneck
I/O bottleneck
Lock contention
✅ SQL Ordered by Elapsed Time
Focus on:
High CPU SQL
High buffer gets
Full scans
✅ Instance Efficiency
Check:
Buffer cache hit ratio
Soft parse %
๐งช 4. ASH Analysis (Real-Time Troubleshooting)
Active Sessions
SELECT sample_time,
session_id,
sql_id,
wait_class,
event
FROM v$active_session_history
ORDER BY sample_time DESC;
๐ฅ 5. SQL Performance Tuning
Identify Expensive SQL
SELECT sql_id,
executions,
elapsed_time/1000000 elapsed_sec,
cpu_time/1000000 cpu_sec
FROM v$sql
ORDER BY elapsed_time DESC;
๐ Execution Plan Analysis
SELECT *
FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,'ALLSTATS LAST'));
๐จ Common SQL Issues
| Problem | Solution |
|---|---|
| Full Table Scan | Create Index |
| Cartesian Join | Fix Join Condition |
| Hard Parsing | Use Bind Variables |
| Bad Execution Plan | Gather Statistics |
๐ฆ 6. Statistics Management
Gather Table Stats
EXEC DBMS_STATS.GATHER_TABLE_STATS('SCOTT','EMP');
Gather Schema Stats
EXEC DBMS_STATS.GATHER_SCHEMA_STATS('SCOTT');
๐พ 7. Memory Tuning
SGA Components
| Component | Purpose |
|---|---|
| Buffer Cache | Data blocks |
| Shared Pool | SQL parsing |
| Large Pool | RMAN/Parallel |
Check Memory Usage
SHOW PARAMETER sga;
SHOW PARAMETER pga;
๐ฅ PGA Analysis
SELECT * FROM v$pgastat;
๐ฝ 8. I/O Performance Tuning
Check File I/O
SELECT file_name,
phyrds,
phywrts
FROM v$datafile df,
v$filestat fs
WHERE df.file# = fs.file#;
๐จ Symptoms of I/O Bottleneck
High
db file sequential readSlow queries
High disk latency
๐ 9. Lock & Blocking Analysis
Blocking Sessions
SELECT blocking_session,
sid,
serial#
FROM v$session
WHERE blocking_session IS NOT NULL;
⚡ Kill Blocking Session
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
๐ 10. Redo & Commit Tuning
Log File Sync Issues
Causes:
Frequent commits
Slow redo disk
Check Redo Waits
SELECT event, total_waits
FROM v$system_event
WHERE event LIKE 'log file%';
๐ง 11. RAC Performance Tuning
Important RAC Waits
| Wait | Meaning |
|---|---|
| gc cr request | Cache fusion |
| gc buffer busy | Block contention |
๐ฅ RAC Tips
Reduce block contention
Optimize interconnect
Partition hot tables
๐ 12. Data Guard Performance
Apply Lag
SELECT name, value
FROM v$dataguard_stats;
๐ 13. Performance Tuning Best Practices
✅ Do’s
Tune SQL first
Use AWR + ASH together
Gather statistics regularly
Monitor trends
❌ Don’ts
Increase memory blindly
Create unnecessary indexes
Ignore execution plans
๐งช 14. Real Production Scenarios
๐ฅ Scenario 1: Database Slow
Root Cause
Full table scan
Solution
Index creation
SQL rewrite
๐ฅ Scenario 2: High CPU
Root Cause
Bad execution plan
Solution
SQL tuning
Stats refresh
๐ฅ Scenario 3: Lock Contention
Root Cause
Uncommitted transaction
Solution
Kill blocker
Application fix
๐ 15. RCA Framework
Always document:
| Area | Details |
|---|---|
| Symptom | What happened |
| Impact | Business impact |
| Root Cause | Why it happened |
| Fix | Resolution |
| Prevention | Future avoidance |
๐ค 16. Interview-Ready Answer
“I approach performance tuning by identifying the top DB time contributors using AWR and ASH. I analyze wait events, expensive SQL, and execution plans to isolate bottlenecks. Then I implement targeted fixes like SQL tuning, indexing, or configuration optimization, and validate improvements through before-vs-after analysis.”
๐ Conclusion
Performance tuning in Oracle Database is not about memorizing commands.
It is about:
Understanding system behavior
Identifying bottlenecks
Performing RCA
Implementing sustainable fixes
๐ Next-Level Topics
You can further expand into:
SQL Plan Management
Adaptive Query Optimization
Exadata tuning
OEM Performance Hub
ASH Analytics
Automatic Indexing
Parallel Query tuning
๐ก Final Thought
“Senior DBAs don’t just fix slow systems.
They understand why systems became slow in the first place.”