| Lesson 2 | The Oracle performance views |
| Objective | List the critical V$ views |
The dynamic performance views (V$ and cluster-wide GV$) expose what the Oracle instance is doing right now. They are not tables on disk; they surface in-memory state maintained by the kernel. Use them to observe wait events, SQL execution, memory, I/O, and session activity—and to validate changes with real data.
Legacy note: Avoid relying on buffer cache hit ratio or SORT_AREA_SIZE. For sorts and joins, use
workarea_size_policy = AUTO with PGA_AGGREGATE_TARGET and an appropriate PGA_AGGREGATE_LIMIT.
For multi-instance (RAC), use GV$ views to see all instances.
V$SYSTEM_EVENT, V$SESSION_EVENT, V$SESSION, V$ACTIVE_SESSION_HISTORY (ASH), V$SYS_TIME_MODEL, V$EVENTMETRICV$SQL, V$SQLSTATS, V$SQLAREA, V$SQL_PLANV$SGASTAT, V$SGAINFO, V$PGASTAT, V$MEMORY_TARGET_ADVICEV$IOSTAT_FILE, V$FILEMETRIC, V$FILESTAT (compat), V$TEMPSEG_USAGEV$LIBRARYCACHE, V$DB_OBJECT_CACHEV$SESSION, V$LOCK, V$LATCH, V$MUTEX_SLEEPSELECT event,
total_waits,
time_waited/100 AS seconds_waited
FROM v$system_event
WHERE wait_class <> 'Idle'
ORDER BY time_waited DESC
FETCH FIRST 10 ROWS ONLY;
SELECT s.sid, s.serial#, s.username, s.module,
s.state, s.wait_class, s.event, s.seconds_in_wait
FROM v$session s
WHERE s.type = 'USER'
ORDER BY s.state DESC, s.seconds_in_wait DESC;
SELECT sql_id, plan_hash_value, executions,
elapsed_time/1e6 AS seconds, rows_processed
FROM v$sql
WHERE executions > 0
ORDER BY elapsed_time DESC
FETCH FIRST 10 ROWS ONLY;
SELECT namespace,
pins, pinhits, (pinhits/pins) AS pin_hit_ratio,
reloads, invalidations
FROM v$librarycache
ORDER BY (reloads + invalidations) DESC;
SELECT pool, name, bytes
FROM v$sgastat
ORDER BY pool NULLS LAST, bytes DESC;
SELECT name, value
FROM v$pgastat
WHERE name IN ('total PGA inuse', 'total PGA allocated',
'bytes processed', 'extra bytes read/written');
SELECT filetype_name,
small_read_megabytes + large_read_megabytes AS read_mb,
small_write_megabytes + large_write_megabytes AS write_mb,
small_read_reqs + large_read_reqs AS read_reqs,
small_write_reqs + large_write_reqs AS write_reqs
FROM v$iostat_file
ORDER BY (read_mb + write_mb) DESC;
SELECT s.sid, s.serial#, u.tablespace, u.blocks, u.segtype
FROM v$session s
JOIN v$tempseg_usage u ON s.saddr = u.session_addr
ORDER BY u.blocks DESC;
SORT_AREA_SIZE: superseded by workarea_size_policy = AUTO and PGA_AGGREGATE_TARGET. Size PGA for your concurrency and workload; validate with V$PGASTAT and temp usage.Licensing tip: ASH and AWR views require the Diagnostics Pack. If not licensed, stick to V$ views and Statspack.
If you are not licensed for the Diagnostics Pack, the long-standing recommendation to use V$ views and Statspack continues to be the correct and compliant approach in Oracle 23c.
It is important to understand the distinctions between the licensed AWR and the free Statspack:
| Feature | Automatic Workload Repository (AWR) | Statspack |
|---|---|---|
| Licensing | Requires Oracle Diagnostics Pack | Free with all editions |
| Data Collection | Automatic and more comprehensive | Manual setup and less detailed |
| Overhead | Lower, integrated into the database kernel | Can be more resource-intensive |
| Analysis Tools | Integrated with ADDM, ASH, and other advisors | Requires manual analysis of reports |
| Storage | Stored in the SYSAUX tablespace |
Stored in a user-defined tablespace |
| Historical Data | Retains a configurable history of performance data | Manual purging of data is typically required |