工作中检查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
阅读(965) | 评论(0) | 转发(0) |