prompt ++++ Temporary tablespace Usage Top 10 …
col program format a20
col terminal format a20
col “MB” format 999999
select sid,program,terminal,osuser,b.used “MB” from v
s
e
s
s
i
o
n
a
,
(
s
e
l
e
c
t
s
e
s
s
i
o
n
a
d
d
r
,
u
s
e
d
f
r
o
m
(
s
e
l
e
c
t
s
e
s
s
i
o
n
a
d
d
r
,
s
u
m
(
b
l
o
c
k
s
)
∗
8192
/
1024
/
1024
u
s
e
d
f
r
o
m
v
session a, (select session_addr,used from ( select session_addr,sum(blocks)*8192/1024/1024 used from v
sessiona,(selectsessionaddr,usedfrom(selectsessionaddr,sum(blocks)∗8192/1024/1024usedfromvsort_usage
group by session_addr
order by 2 desc)
where rownum < 11
) b
where a.saddr=b.session_addr;
prompt ++++ Temporary tablespace Usage Top 10 …
col program format a20
col terminal format a20
col “MB” format 999999
set linesize 300
set pagesize 1000
select sid,sql_id,prev_sql_id,program,terminal,osuser,b.used “MB” from v
s
e
s
s
i
o
n
a
,
(
s
e
l
e
c
t
s
e
s
s
i
o
n
a
d
d
r
,
u
s
e
d
f
r
o
m
(
s
e
l
e
c
t
s
e
s
s
i
o
n
a
d
d
r
,
s
u
m
(
b
l
o
c
k
s
)
∗
8192
/
1024
/
1024
u
s
e
d
f
r
o
m
v
session a, (select session_addr,used from ( select session_addr,sum(blocks)*8192/1024/1024 used from v
sessiona,(selectsessionaddr,usedfrom(selectsessionaddr,sum(blocks)∗8192/1024/1024usedfromvsort_usage
group by session_addr
order by 2 desc)
) b
where a.saddr=b.session_addr;
For DW
Select round(sum(blocks)*16/1024/1024) “TempUsed(GB)”, t.username, session_num, sid, b.hash_value, b.plan_hash_value, b.sql_text
from v
t
e
m
p
s
e
g
u
s
a
g
e
t
,
v
tempseg_usage t, v
tempsegusaget,vsession s, v$sqlarea b
Where S.SERIAL# = t.session_num
and s.sql_address = b.address
group by t.username, session_num, sid, b.hash_value, b.plan_hash_value, b.sql_text order by 1 desc;
For DW
Select round(sum(blocks)*16/1024/1024) “TempUsed(GB)”, t.username, session_num, sid, b.hash_value, b.plan_hash_value, b.sql_text
from v
t
e
m
p
s
e
g
u
s
a
g
e
t
,
v
tempseg_usage t, v
tempsegusaget,vsession s, v$sqlarea b
Where S.SERIAL# = t.session_num
and s.sql_address = b.address
group by t.username, session_num, sid, b.hash_value, b.plan_hash_value, b.sql_text order by 1 desc;
prompt +++++Undo Block Usage Top 5 …
select sid,used_ublk,used_urec,log_io,phy_io*8/1024,sql_id,prev_sql_id
from (select rownum,b.sid,used_ublk,used_urec,log_io,phy_io,b.sql_id,b.prev_sql_id
from v
t
r
a
n
s
a
c
t
i
o
n
a
,
v
transaction a,v
transactiona,vsession b
where a.addr = b.taddr
order by used_ublk desc) transize
where rownum <6;
prompt "Session/Process/Transaction: total "
prompt +++++ Session/Process/Transaction: total …
select ‘Session_Stats’ stats, to_char(sysdate, ‘RRRR-MM-DD HH24:MI:SS’) curr_time, inst_id, count(*) sess_num from gv$session group
by inst_id;
select ‘Process_Stats’ stats, to_char(sysdate, ‘RRRR-MM-DD HH24:MI:SS’) curr_time, inst_id, count(*) proc_num from gv$process group
by inst_id;
select ‘Trans_Stats’ stats, to_char(sysdate, ‘RRRR-MM-DD HH24:MI:SS’) curr_time, inst_id, count(*) tranc_num from gv$transaction group by inst_id;
PROMPT “SPACE AVAILABLE IN TABLESPACES”
prompt +++++ Tablespaces Usage …
set pagesize 1000
set linesize 120
select b.tablespace_name,c.extent_management,c.SEGMENT_SPACE_MANAGEMENT,
b.Tot_Size,b.Tot_Free,b.Pct_Used from
(select a.tablespace_name,round(sum(a.tots)/1024/1024,2) Tot_Size,
round(sum(a.sumb)/1024/1024,2) Tot_Free,
round(100-(sum(a.sumb)100/sum(a.tots)),2) Pct_Used
–, sum(a.largest) Max_Free,sum(a.chunks) Chunks_Free
from
(
select tablespace_name,0 tots,sum(bytes) sumb,
max(bytes) largest,count() chunks
from dba_free_space a
group by tablespace_name
union
select tablespace_name,sum(bytes) tots,0,0,0 from
dba_data_files
group by tablespace_name) a
group by a.tablespace_name) b, dba_tablespaces c
where b.tablespace_name=c.tablespace_name
order by Pct_Used;
select * from (
select b.tablespace_name,c.extent_management,c.SEGMENT_SPACE_MANAGEMENT,
b.Tot_Size,b.Tot_Free,b.Pct_Used from
(select a.tablespace_name,round(sum(a.tots)/1024/1024,2) Tot_Size,
round(sum(a.sumb)/1024/1024,2) Tot_Free,
round(100-(sum(a.sumb)100/sum(a.tots)),2) Pct_Used
–, sum(a.largest) Max_Free,sum(a.chunks) Chunks_Free
from
(
select tablespace_name,0 tots,sum(bytes) sumb,
max(bytes) largest,count() chunks
from dba_free_space a
group by tablespace_name
union
select tablespace_name,sum(bytes) tots,0,0,0 from
dba_data_files
group by tablespace_name) a
group by a.tablespace_name) b, dba_tablespaces c
where b.tablespace_name=c.tablespace_name) k
where k.tablespace_name=‘LOB2’
PROMPT “Wait Event”
prompt +++++ Wait Event…
select a.sid,a.event,a.p1,a.p2,a.p3,b.sql_id from v
s
e
s
s
i
o
n
w
a
i
t
a
,
v
session_wait a,v
sessionwaita,vsession b
where a.event not in
(‘queue messages’,‘pmon timer’,‘smon timer’,‘pipe get’,‘SQL*Net message from client’,‘rdbms ipc message’,‘wakeup time manager’)
and a.sid=b.sid order by event;
PROMPT “Wait Event”
prompt +++++ Wait Event…
select a.sid,a.event,a.p1,a.p2,a.p3,b.sql_id from v
s
e
s
s
i
o
n
w
a
i
t
a
,
v
session_wait a,v
sessionwaita,vsession b
where a.event not in
(‘queue messages’,‘pmon timer’,‘smon timer’,‘pipe get’,‘SQL*Net message from client’,‘rdbms ipc message’,‘wakeup time manager’)
and a.sid=b.sid order by event;
Prompt “Enqueue Info”
prompt +++++ Enqueue Info…
SELECT DECODE(request,0,'Holder: ‘,’ |–Waiter: ')||sid sess,
id1, id2, lmode, request, type,block,inst_id
FROM GV
L
O
C
K
W
H
E
R
E
(
i
d
1
,
i
d
2
,
t
y
p
e
)
I
N
(
S
E
L
E
C
T
i
d
1
,
i
d
2
,
t
y
p
e
F
R
O
M
G
V
LOCK WHERE (id1, id2, type) IN (SELECT id1, id2, type FROM GV
LOCKWHERE(id1,id2,type)IN(SELECTid1,id2,typeFROMGVLOCK WHERE request>0 )
ORDER BY id1, request ;
Prompt “Cursor Monitoring”
prompt ++++ cursor info ++++
select max(cur) max_curs,min(cur) min_curs,avg(cur) avr_curs
from (select sid,count(*) cur from v$open_cursor
group by sid);
Prompt “Rpt User Usage”
prompt +++ rptuser usage ++++
select username,sid,module,program,machine,sql_id,prev_sql_id,status
from v$session where username=‘RPTUSER’;