代码拉取完成,页面将自动刷新
WITH
events AS (
SELECT
SUBSTR(TRIM(h.sql_id||' '||h.program||' '||
CASE h.module WHEN h.program THEN NULL ELSE h.module END), 1, 128) source,
h.dbid,
COUNT(*) samples
FROM dba_hist_active_sess_history h,
dba_hist_snapshot s
WHERE h.wait_class = TRIM('&Event_Class') AND h.event = TRIM('&Event_Name')
AND h.snap_id BETWEEN &Begin_Snap AND &End_Snap
AND h.dbid = &dbid
AND s.snap_id = h.snap_id
AND s.dbid = h.dbid
AND s.instance_number = h.instance_number
GROUP BY
h.sql_id,
h.program,
h.module,
h.dbid
ORDER BY
3 DESC
),
total AS (
SELECT SUM(samples) samples,
SUM(CASE WHEN ROWNUM > 15 THEN samples ELSE 0 END) others
FROM events
)
SELECT e.source,
e.samples,
ROUND(100 * e.samples / t.samples, 1) percent,
(SELECT DBMS_LOB.SUBSTR(s.sql_text, 1000, 1) FROM dba_hist_sqltext s WHERE s.sql_id = SUBSTR(e.source, 1, 13) AND s.dbid = e.dbid AND ROWNUM = 1) sql_text
FROM events e,
total t
WHERE ROWNUM 0.1
UNION ALL
SELECT 'Others',
others samples,
ROUND(100 * others / samples, 1) percent,
NULL sql_text
FROM total
WHERE others > 0
AND ROUND(100 * others / samples, 1) > 0.1;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。