-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchk_full_scans.sql
More file actions
37 lines (26 loc) · 1.25 KB
/
chk_full_scans.sql
File metadata and controls
37 lines (26 loc) · 1.25 KB
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
35
36
37
--Check Full Scans in DB
COLUMN user_process FORMAT A20 HEADING "Username(Process ID)"
COLUMN short_scans FORMAT 999,999,999 HEADING "Short Scans"
COLUMN long_scans FORMAT 999,999,999 HEADING "Long Scans"
COLUMN blocks_retrieved FORMAT 999,999,999 HEADING "Blocks Retrieved"
COLUMN avr_scan_blocks FORMAT 999,999,999.99 HEADING "Avr Scan (blocks)"
SELECT SS.username || '(' || se.sid || ') ' AS user_process,
Sum( Decode(name, 'table scans (short tables)', value) ) AS short_scans,
Sum( Decode(name, 'table scans (long tables)', value) ) AS long_scans,
Sum( Decode(name, 'table scan blocks gotten', value) ) AS block_retrieved,
(Sum( Decode(name, 'table scan blocks gotten', value) ) - (Sum( Decode(name, 'table scans (short tables)', value) ) * 5)),
Sum( Decode(name, 'table scans (long tables)', value) ) AS avr_scan_blocks
FROM v$session SS,
v$sesstat SE,
v$statname SN
WHERE SE.statistic# = SN.statistic#
AND (name Like '%table scans (short tables)%'
OR
name Like '%table scans (long tables)%'
OR
name Like '%table scan blocks gotten%')
AND SE.sid = SS.sid
AND SS.username IS NOT NULL
GROUP BY SS.username || '(' || SE.sid || ') '
HAVING Sum( Decode(name, 'table scans (long tables)', value) ) <> 0
ORDER BY long_scans DESC;