This query identifies the top 10 wait events in the last 30 minutes, showing their frequency and percentage of total wait time:

SELECT
    NVL(event, 'ON CPU') AS event,
    NVL(wait_class, 'CPU') AS wait_class,
    COUNT(*) AS total_wait_time,
    TO_CHAR(100 * TRUNC(RATIO_TO_REPORT(COUNT(*)) OVER (), 6), 'FM990.9999') || '%' AS "%"
FROM
    v$active_session_history
WHERE
    sample_time > SYSDATE - 30 / 60 / 24
GROUP BY
    event,
    wait_class
ORDER BY
    total_wait_time DESC
    fetch first 10 rows only;

Sample output:

EVENT                         WAIT_CLASS      TOTAL_WAIT_TIME %
ON CPU                        CPU                        5092 96.003%
db file sequential read       User I/O                     43 0.8107%
latch free                    Other                        38 0.7164%
library cache lock            Concurrency                  36 0.6787%
Failed Logon Delay            Other                        30 0.5656%
db file parallel write        System I/O                   23 0.4336%
PX Deq: Slave Session Stats   Other                        13 0.245%
log file parallel write       System I/O                   10 0.1885%
control file parallel write   System I/O                    6 0.1131%
db file async I/O submit      System I/O                    4 0.0754%

10 rows selected.

As shown, CPU usage dominates the session activity.

I’m Yuan

Welcome to the blog of a performance maven in Oracle & MySQL. Feel free to contact me to share and discuss database knowledge.

My 20 Oracle Certifications

A screenshot from certview.oracle.com

My Book

MySQL 8.0 Operations and Optimization

Let’s connect