forked from tanelpoder/tpt-oracle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathash_storage.sql
35 lines (32 loc) · 1.4 KB
/
ash_storage.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
COL wait_event FOR A45 TRUNCATE
COL ash_storage_graph HEAD "GRAPHIC" JUST CENTER FOR A12
SELECT
CASE WHEN sql_plan_options LIKE '%STORAGE%' THEN sql_plan_operation ELSE 'not storage-aware' END sql_plan_operation
, CASE WHEN sql_plan_options LIKE '%STORAGE%' THEN sql_plan_options ELSE 'not storage-aware' END sql_plan_options
, CASE WHEN sql_plan_options LIKE '%STORAGE%' THEN
CASE WHEN session_state = 'WAITING' THEN event ELSE 'ON CPU' END
ELSE
'not storage-aware'
END wait_event
, COUNT(*)
, ROUND(RATIO_TO_REPORT(COUNT(*)) OVER() * 100 ,1) pct
, '|'||RPAD(NVL(RPAD('#', ROUND (10 * RATIO_TO_REPORT(COUNT(*)) OVER()), '#'),' '), 10)||'|' ash_storage_graph
FROM
v$active_session_history
WHERE
1=1
AND sample_time BETWEEN sysdate-1/24/12 AND sysdate
-- AND sql_plan_options LIKE '%STORAGE%'
GROUP BY
CASE WHEN sql_plan_options LIKE '%STORAGE%' THEN sql_plan_operation ELSE 'not storage-aware' END
, CASE WHEN sql_plan_options LIKE '%STORAGE%' THEN sql_plan_options ELSE 'not storage-aware' END
, CASE WHEN sql_plan_options LIKE '%STORAGE%' THEN
CASE WHEN session_state = 'WAITING' THEN event ELSE 'ON CPU' END
ELSE
'not storage-aware'
END
ORDER BY
COUNT(*) DESC
/