Oracle
Oracle ASH and AWR: a field guide for the rest of us
ASH and AWR are two of the best performance views any database has shipped — but they sit behind the Diagnostics Pack license. This is how to get 90% of the value, with or without it.
Oracle gives you two of the best performance views any database has ever shipped — Active Session History (ASH) and Automatic Workload Repository (AWR). The catch: both live behind the Diagnostics Pack, which is licensed separately. This guide is about getting 90% of the value without paying for either.
On this page
ASH: a live tail of every session
ASH is the cheapest powerful telemetry in Oracle. Every second, the kernel samplesv$session and writes one row per active session into a circular in-memory buffer (v$active_session_history). It costs almost nothing — sampling is on the SGA path — and it captures things the SQL trace can’t: blocked sessions, wait events, the SQL text and module they were running.
- Sample rate: 1 Hz from
v$session, only the rows where the session was on CPU or in a wait. - Retention: usually a few hours in memory before AWR persists samples to
dba_hist_active_sess_history. - What it captures: session_id, sql_id, module, action, event, wait_class, blocking_session — enough to reconstruct any incident.
AWR: snapshots over time
AWR is the long-form version. Every hour, Oracle takes a snapshot of every dynamic performance view and writes a delta into the SYSAUX tablespace. The famous awrrpt.sql report is just a formatted diff between two snapshots.
The most useful AWR sections are Top Timed Events (where time was spent),SQL Ordered by Elapsed Time (which signature burned it), and Instance Activity Stats (raw counters per second). If you only read three sections, those.
Without the Diagnostics Pack
Oracle’s licensing splits ASH and AWR behind the Diagnostics Pack. If you don’t have it, querying v$active_session_history is technically a license violation. There are two open alternatives:
- Statspack: the pre-AWR ancestor. Free, ships with Oracle, lacks ASH but covers most of the AWR snapshot story. Install with
@?/rdbms/admin/spcreate.sql, schedule snapshots, generate reports withspreport.sql. - S-ASH (open ASH simulation): a community project that polls
v$sessionat 1 Hz from outside the database, writes to a separate schema, and approximates ASH closely enough for incident analysis. - Direct sampling from a sidecar: the path the Obsfly Oracle agent takes — sample
gv$sessionat 1 Hz over a regular SELECT (which is licensed), ship the rows out for storage and analysis. Same telemetry, different storage.
Queries you should run today
These three queries cover most incident triage on an Oracle box. The first works in Statspack; the second and third need ASH (or a sidecar equivalent).
-- 1. Top wait events in the last hour (Statspack OK)
SELECT event, total_waits, time_waited_micro/1e6 AS time_waited_s
FROM v$system_event
WHERE wait_class != 'Idle'
ORDER BY time_waited_micro DESC
FETCH FIRST 10 ROWS ONLY;
-- 2. Top SQL by ASH-sampled time (Diag Pack)
SELECT sql_id, COUNT(*) AS samples, COUNT(DISTINCT session_id) AS sessions
FROM v$active_session_history
WHERE sample_time > SYSTIMESTAMP - INTERVAL '1' HOUR
GROUP BY sql_id
ORDER BY samples DESC
FETCH FIRST 10 ROWS ONLY;
-- 3. Blocked sessions right now (no Diag Pack needed)
SELECT s.sid, s.serial#, s.username, s.event, s.blocking_session,
s.sql_id, s.last_call_et AS seconds_in_event
FROM v$session s
WHERE s.blocking_session IS NOT NULL
ORDER BY s.last_call_et DESC;FAQ
How much does the Diagnostics Pack cost?+
Does ASH work on Oracle Standard Edition?+
What about Oracle Cloud and Autonomous Database?+
Why doesn't AWR show me lock chains the way Postgres pg_locks does?+
Keep reading
SQL Server
SQL Server Query Store: the field guide most teams skip
Query Store is the single biggest reason a SQL Server upgrade past 2016 was worth the weekend. The settings that matter, the DMVs you actually use, and how to catch a plan regression in two queries.
SRE
Database SLOs that aren't useless: a working definition
Most DB SLOs are 'CPU under 80%.' That's a budget alert, not a service-level objective. Here's how to define an SLO an executive can sign off on and an engineer can act on.
BYOC
Why regulated SaaS can't use Datadog DBM — and the BYOC fix
Walking through the architecture of a BYOC observability deployment: where data lives, what crosses the boundary, and how to satisfy SOC2 / HIPAA / GDPR without giving up the UX.