工作中检查oracle数据库当前会话。
青铜 dba,爱用:
select event,count(0) from v$session group by event;
白银 dba,改为:
select event,count(0) from v$session where wait_class<>'Idle' group by event order by 2 desc;
黄金 dba,改为:
SELECT * FROM (SELECT sid, username,event,sql_id,BLOCKING_INSTANCE blk_inst,
BLOCKING_SESSION blk_sid,program,machine,to_char(logon_time, 'yy-mm-dd hh24:mi:ss')
logon_time,SECONDS_IN_WAIT seconds,state FROM V$SESSION WHERE (WAIT_CLASS <> 'Idle') or state <> 'WAITING' ORDER BY SECONDS_IN_WAIT DESC, event)
一个session的状态要么是在等待,要么是在ON CPU,v$session.state这个列可以判断这个状态。有且只有v$session.state='WAITING'的时候,才代表这个session当前正在等待这个event,否则代表这个session在ON CPU。
王者:
select event from v$session order by 1
阅读(1085) | 评论(0) | 转发(0) |