查看等待事件

--v$session_wait视图中的p1、p2、p3表示等待事件的具体含义,如果Wait Event是db file scattered read,那么p1=file_id/p2=block_id/p3=blocks,然后通过dba_extents即可

确定出热点对象.
--如果是latch free的话,那么p2为闩锁号,它指向v$latch.

--求等待事件及其对应的latch
col event format a32;
col name format a32;
select sid,event,p1 as "p1 as file_id", p2 as "p2 as block_id/latch", p3 as "p3 as blocks",l.name
 from v$session_wait sw,v$latch l
 where event not like '%SQL%' and event not like '%rdbms%' and event not like '%mon%' and sw.p2 = l.latch#(+);

--求等待事件及其热点对象
col owner format a18;
col segment_name format a32;
col segment_type format a32;
select owner, segment_name, segment_type from dba_extents
 where file_id = &file_id and &block_id between block_id and block_id + &blocks - 1;

--综合以上两条SQL,同时显示latch及热点对象(速度较慢)
select sw.sid, event, l.name, de.segment_name from v$session_wait sw, v$latch l, dba_extents de
 where event not like '%SQL%' and event not like '%rdbms%' and event not like '%mon%'
 and sw.p2 = l.latch#(+) and sw.p1 = de.file_id(+) and p2 between de.block_id and de.block_id + de.blocks - 1;

 

--如果是非空闲等待事件,通过等待会话的SID可以求出该会话在执行的SQL
select sql_text from v$sqltext_with_newlines st, v$session se
  where st.address = se.sql_address and st.hash_value = se.sql_hash_value and se.sid = &wait_sid order by piece;

 

转载于:https://www.cnblogs.com/rootq/archive/2009/01/31/1381662.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值