找出数据库中哪个查询的运行时间最长:
select s.sql_text from v$sql s, v$undostat u
where u.maxqueryid=s.sql_id;
可以将v$transaction和v$session视图连接起来,找出当前执行的事务中,使用undo空间最多的会话:
select s.sid, s.username, t.used_urec, t.used_ublk
from v$session s, v$transaction t
where s.saddr = t.ses_addr
order by t.used_ublk desc;
找出实例中当前哪个会话使用了最多的undo空间:
select s.sid, t.name, s.value
from v$sesstat s, v$statname t
where s.statistic# = t.statistic#
and t.name = 'undo change vector size'
order by s.value desc;
select sql.sql_text sql_text,
t.USED_UREC Records,
t.USED_UBLK Blocks,
(t.USED_UBLK * 8192 / 1024) KBytes
from v$transaction t, v$session s, v$sql sql
where t.addr = s.taddr
and s.sql_id = sql.sql_id
and s.username = '&USERNAME'
order by t.used_ublk desc;
USED_UREC 列显示所使用的undo记录数量
USED_UBLK 显示事务所占用的undo数据块数