手机版
你好,游客 登录 注册
背景:
阅读新闻

Oracle OWI 等待事件视图(v$session_wait/v$session_event/v$system_event)

[日期:2013-04-16] 来源:Linux社区  作者:robinson [字体:大 中 小]

8、演示中使用到的脚本

a、wait_event_by_sid.sql
robin@SZDB:~/dba_scripts/custom/sql> more wait_event_by_sid.sql
SELECT event, time_waited AS time_spent
  FROM v$session_event
 WHERE sid = &sid
      AND wait_class<>'Idle'
      AND event NOT IN
              ('Null event',
              'client message',
              'KXFX: Execution Message Dequeue - Slave',
              'PX Deq: Execution Msg',
              'KXFQ: kxfqdeq - normal deqeue',
              'PX Deq: Table Q Normal',
              'Wait for credit - send blocked',
              'PX Deq Credit: send blkd',
              'Wait for credit - need buffer to send',
              'PX Deq Credit: need buffer',
              'Wait for credit - free buffer',
              'PX Deq Credit: free buffer',
              'parallel query dequeue wait',
              'PX Deque wait',
              'Parallel Query Idle Wait - Slaves',
              'PX Idle Wait',
              'slave wait',
              'dispatcher timer',
              'virtual circuit status',
              'pipe get',
              'rdbms ipc message',
              'rdbms ipc reply',
              'pmon timer',
              'smon timer',
              'PL/SQL lock timer',
              'SQL*Net message from client',
              'SQL*Net message to client',
              'SQL*Net break/reset to client',
              'SQL*Net more data to client',
              'rdbms ipc message',
              'WMON goes to sleep')
UNION ALL
SELECT b.name, a.VALUE
  FROM v$sesstat a, v$statname b
 WHERE a.statistic# = b.statistic# AND b.name = 'CPU used when call started' AND a.sid = &sid;

b、wait_event_inst_lvl.sql
robin@SZDB:~/dba_scripts/custom/sql> more wait_event_inst_lvl.sql
SET LINES 160
SET NUMWIDTH 18
COL class FOR a15
COL event FOR a30
COL total_waits FOR 999,999,999
COL total_timeouts FOR 999,999,999
COL time_waited FOR 999,999,999,999
COL average_wait FOR 999,999,999,999
COL event FORMAT a30 WRAP
COL wait_class FORMAT a20

  SELECT b.wait_class,
        a.event,
        total_waits,
        total_timeouts,
        time_waited,
        average_wait,
        c.startup_time
    FROM v$system_event a, v$event_name b, v$instance c
  WHERE a.event = b.name
        AND UPPER (a.event) LIKE
                DECODE (UPPER ('&input_event_name'),
                        'ALL', UPPER (a.event),
                        UPPER ('%&input_event_name%'))
        AND b.wait_class<>'Idle'
        AND a.event NOT IN
            ('Null event',
              'client message',
              'KXFX: Execution Message Dequeue - Slave',
              'PX Deq: Execution Msg',
              'KXFQ: kxfqdeq - normal deqeue',
              'PX Deq: Table Q Normal',
              'Wait for credit - send blocked',
              'PX Deq Credit: send blkd',
              'Wait for credit - need buffer to send',
              'PX Deq Credit: need buffer',
              'Wait for credit - free buffer',
              'PX Deq Credit: free buffer',
              'parallel query dequeue wait',
              'PX Deque wait',
              'Parallel Query Idle Wait - Slaves',
              'PX Idle Wait',
              'slave wait',
              'dispatcher timer',
              'virtual circuit status',
              'pipe get',
              'rdbms ipc message',
              'rdbms ipc reply',
              'pmon timer',
              'smon timer',
              'PL/SQL lock timer',
              'SQL*Net message from client',
              'SQL*Net message to client',
              'SQL*Net break/reset to client',
              'SQL*Net more data to client',
              'rdbms ipc message',
              'WMON goes to sleep')
ORDER BY b.wait_class, a.time_waited;

9、小结

a、参数timed_statistics与statistics_level影响等待事件时间片的收集

b、v$event_name数据库字典(此处不是动态视图)提供了所有等待事件相关的名称,类别,ID等

c、v$session_wait为当前实例的session提供当前正在等待的事件或资源(单一事件,一个session对应一条记录)

d、v$session_event提供了每个session的每一个等待事件的总等待时间,已等待时间以及最大等待时间

e、v$system_event提供的是自实例启动以来所有等待时间的总和,包括等待的总次数,总超时,是所有会话的在所有等待事件上的汇总。

f、如果用户说某个session响应比较慢,排除Cpu过度繁忙之外,一定是该session 处于某个等待事件而导致session变慢。

g、根据上述描述的相关视图,可以快速定位指定session变慢的真正原因。

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

linux
相关资讯       Oracle视图  Oracle OWI等待事件视图 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款