Diagnosing and Resolving Oracle Performance Issues
From the Database System curriculum
TL;DR
Oracle database performance issues often stem from slow SQL queries, inadequate indexing, or resource bottlenecks like CPU, I/O, or memory. You'll use tools like AWR, ADDM, and v$sql to identify the root cause, then apply targeted solutions such as tuning SQL, adding indexes, or adjusting instance parameters. Proactive monitoring and regular tuning are key to maintaining a healthy Oracle database.
1. The Mental Model
Think of your Oracle database as a busy kitchen. If food orders (queries) are taking too long, it could be the chef (CPU), the ingredients (I/O), the recipe (SQL), or even missing tools (indexes). Your job is to find why the kitchen is slow and fix it.
2. The Core Material
Diagnosing Oracle performance issues involves a systematic approach to pinpoint the bottleneck. Resolving them means applying specific, data-driven solutions.
Identifying Performance Bottlenecks

Photo by Crab Lens on Pexels
Oracle provides several built-in tools to help you identify where time is being spent.
- Automatic Workload Repository (AWR): AWR collects, processes, and maintains performance statistics for problem detection and self-tuning. It captures snapshots of performance data over time. You'll typically look at AWR reports to see top wait events, top SQL statements, and resource usage trends.
- Automatic Database Diagnostic Monitor (ADDM): ADDM automatically analyzes AWR data at regular intervals, identifies potential performance bottlenecks, and recommends solutions. It's great for getting a quick diagnosis.
v$sessionandv$sqlviews: These dynamic performance views provide real-time information.v$sessionshows what active sessions are doing (waiting, running CPU), whilev$sqlcontains details about SQL statements executed in the SGA (like execution counts, disk reads, CPU time).- SQL Trace/TKPROF: For deep dives into specific SQL statements, SQL Trace records detailed execution statistics. TKPROF then formats this trace file into a readable report showing execution plans, CPU time, elapsed time, and I/O for each step.
When looking at performance data, focus on:
1. Wait Events: What is the database waiting for? (e.g., db file sequential read for disk I/O, CPU + IO when busy, latch: cache buffers chains for contention).
2. Top SQL: Which SQL statements consume the most resources (CPU, I/O, elapsed time)?
3. Resource Usage: Are CPU, memory, or I/O at their limits?
Common Performance Issues and Solutions

Photo by Matheus Bertelli on Pexels
Once you've identified the bottleneck, here are common issues and how to address them:
Slow SQL Queries
This is often the biggest culprit.
* Diagnosis: AWR reports (Top SQL section), v$sql (ordering by elapsed_time or cpu_time), SQL Trace.
* Solution:
* SQL Tuning: Rewrite inefficient queries. Avoid SELECT *, use proper WHERE clauses, join tables efficiently.
* Indexing: Create appropriate indexes to speed up data retrieval. A missing index often leads to full table scans.
* Execution Plans: Understand how Oracle executes your SQL (using EXPLAIN PLAN or DBMS_XPLAN). Look for full table scans on large tables or expensive joins.
Inefficient I/O
If the database is constantly waiting for data from disk.
* Diagnosis: AWR (Top Wait Events showing db file sequential read, db file scattered read), OS-level I/O tools.
* Solution:
* Indexing: Reduces the amount of data read from disk.
* Caching: Ensure frequently accessed data is in the buffer cache (SGA). Increase DB_CACHE_SIZE if necessary.
* Storage Optimization: Improve disk subsystem performance (e.g., faster disks, RAID configuration).
* Partitioning: Break large tables into smaller, more manageable pieces to reduce I/O for specific queries.
CPU Bottlenecks
When the CPU is constantly at 100% utilization.
* Diagnosis: AWR (CPU usage statistics), OS monitoring tools.
* Solution:
* SQL Tuning: Reduce CPU-intensive operations (e.g., complex calculations, large sorts).
* Indexing: Again, reduces the data processed, thus less CPU.
* Parallelism: Use parallel query execution for complex, long-running queries if your system can benefit.
* Hardware Upgrade: More CPUs or faster CPUs.
Memory Issues (SGA/PGA)
Incorrect sizing of Oracle's memory areas can lead to excessive I/O or inefficient processing.
* Diagnosis: AWR (SGA/PGA advisory sections), v$sga_info`, `v$pgastat.
* Solution:
* SGA Tuning: Adjust DB_CACHE_SIZE (for data blocks), SHARED_POOL_SIZE (for SQL parsing), LARGE_POOL_SIZE (for certain features). Use Automatic Shared Memory Management (ASMM) or Automatic Memory Management (AMM).
* PGA Tuning: Set PGA_AGGREGATE_TARGET to allow Oracle to manage session memory for sorting and hashing operations.
Here's a diagram illustrating the general process:
graph TD
A["Performance Complaint/Slowdown"] --> B{Initial Diagnosis: AWR/ADDM};
B --> C{Identify Top Wait Events & Top SQL};
C --> D{Is it SQL-related?};
D -- Yes --> E["Tune SQL: Review Execution Plan, Add/Modify Indexes"];
D -- No --> F{Is it I/O-related?};
F -- Yes --> G["Optimize I/O: Caching, Storage, Partitioning"];
F -- No --> H{Is it CPU-related?};
H -- Yes --> I["Reduce CPU usage: SQL tuning, Parallelism, Hardware"];
H -- No --> J{Is it Memory-related?};
J -- Yes --> K["Tune Memory: SGA/PGA Parameters"];
K --> L["Monitor & Re-evaluate"];
I --> L;
G --> L;
E --> L;
L --> B;
3. Worked Example
Let's say users report that a specific report query (SELECT customer_name, order_date, total_amount FROM orders o JOIN customers c ON o.customer_id = c.customer_id WHERE order_date BETWEEN '01-JAN-2023' AND '31-JAN-2023' ORDER BY total_amount DESC;) is very slow.
-
Diagnosis: You run an AWR report covering the time the report runs. In the "Top SQL by Elapsed Time" section, you find our query consuming 90% of the elapsed time. Looking at its execution plan (perhaps from
v$sql_planorEXPLAIN PLAN), you see a "FULL TABLE SCAN" on theORDERStable and a "NESTED LOOPS" join, where thecustomerstable is accessed repeatedly. The wait events associated with this query are predominantlydb file sequential read. -
Analysis:
db file sequential readsuggests a lot of single-block I/O, often due to index usage (or lack thereof, if the index isn't selective).- The full table scan on
ORDERSfor a date range means Oracle is reading every row in the table to find matches, which is inefficient if the table is large. - The
ORDER BY total_amount DESCmight also be causing a large sort operation if there's no index ontotal_amount.
-
Solution:
- Index on
order_date: TheWHEREclause filters byorder_date. Creating an index onorders(order_date)will allow Oracle to quickly find relevant orders without a full table scan. - Composite Index for Sorting: To help with the
ORDER BY total_amount DESC, you might consider a composite index likeorders(order_date, total_amount DESC). This allows Oracle to use the index for both filtering and sorting, potentially avoiding a separate sort step. - Check existing indexes: Ensure
customer_idcolumns in both tables are indexed for efficient join operations.
- Index on
After implementing the index on orders(order_date), you rerun the query and check the execution plan again. You now see an "INDEX RANGE SCAN" on ORDERS for the order_date column, and the query completes much faster.
4. Key Takeaways
- Always start with AWR/ADDM for a high-level overview of performance issues; they point you to the biggest problems.
v$sqlis crucial for identifying resource-intensive SQL statements in real-time.- Wait events tell you what the database is spending its time doing, guiding your investigation.
- Inefficient SQL and missing/improper indexes are the most common performance culprits.
- Understand execution plans to see how Oracle processes your queries and identify bottlenecks.
- Don't just add indexes blindly; analyze the query patterns and data distribution first.
- Memory (SGA/PGA) and I/O tuning are critical after SQL and index tuning, but less common initial bottlenecks for typical applications.
Common mistakes to avoid:
- Jumping to conclusions: Don't assume you know the problem; let the data (AWR, ADDM, `v
Frequently asked about Diagnosing and Resolving Oracle Performance Issues
Study this next
Get the full Database System curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Save this course free