View top wait events
Oracle
SELECT event, total_waits, time_waited, ROUND(time_waited/100,2) AS sec_waited
FROM v$system_event
WHERE wait_class <> 'Idle'
ORDER BY time_waited DESC
FETCH FIRST 20 ROWS ONLY;
-- For real-time analysis: v$active_session_history (ASH)v$system_event gives cumulative wait events; v$active_session_history gives active session sampling for the last few minutes (requires the Diagnostics Pack license).
PostgreSQL
SELECT wait_event_type, wait_event, count(*)
FROM pg_stat_activity
WHERE wait_event IS NOT NULL AND state = 'active'
GROUP BY 1, 2
ORDER BY 3 DESC;pg_stat_activity shows the current wait state; sampling it repeatedly (polling) reveals the most frequent wait events.
MySQL
SELECT event_name, count_star, sum_timer_wait,
ROUND(sum_timer_wait/1000000000000, 2) AS sec_waited
FROM performance_schema.events_waits_summary_global_by_event_name
WHERE count_star > 0
ORDER BY sum_timer_wait DESC
LIMIT 20;events_waits_summary_global_by_event_name gives total wait times per event (in picoseconds); wait instruments must be enabled.
SQL Server
SELECT wait_type, waiting_tasks_count, wait_time_ms,
signal_wait_time_ms, wait_time_ms - signal_wait_time_ms AS resource_wait_ms
FROM sys.dm_os_wait_stats
WHERE wait_time_ms > 0
ORDER BY wait_time_ms DESC;sys.dm_os_wait_stats shows cumulative wait types since instance startup; it can be reset with DBCC SQLPERF.
MongoDB
db.serverStatus().wiredTiger.concurrentTransactions
// For general waits/congestion:
// db.serverStatus().globalLock and db.serverStatus().wiredTiger.cacheWiredTiger has no classic wait events; exhaustion of concurrentTransactions (tickets), globalLock.currentQueue, and cache pressure indicate congestion.
Redis
CONFIG SET latency-monitor-threshold 100
LATENCY LATEST
LATENCY HISTORY command
# For the slowest commands: SLOWLOG GET 10Once the latency monitor threshold is set, LATENCY LATEST/HISTORY reports the events causing the most latency.
Elasticsearch
GET _nodes/hot_threads_nodes/hot_threads reveals bottlenecks by giving stack traces of the threads consuming the most CPU.