oracle 响应时间分析(二)

会话级别

--当然也可以查看具体哪个SESSION 

[sql]  view plain  copy
 print ?
  1. select a.sid,  
  2.        b.username,  
  3.        a.wait_class,  
  4.        a.total_waits,  
  5.        round((a.time_waited / 100), 2) time_waited_secs  
  6.   from sys.v_$session_wait_class a, sys.v_$session b  
  7.  where b.sid = a.sid  
  8.    and b.username is not null  
  9.    and a.wait_class != 'Idle'  
  10.  order by 5 desc;  



--下钻到某个时间的所有回话

[sql]  view plain  copy
 print ?
  1. <span style="font-weight: normal;">select sess_id,  
  2.        username,  
  3.        program,  
  4.        wait_event,  
  5.        sess_time,  
  6.        round(100 * (sess_time / total_time), 2) pct_time_waited  
  7.   from (select a.session_id sess_id,  
  8.                decode(session_type, 'background', session_type, c.username) username,  
  9.                a.program program,  
  10.                b.name wait_event,  
  11.                sum(a.time_waited) sess_time  
  12.           from sys.v_$active_session_history a,  
  13.                sys.v_$event_name             b,  
  14.                sys.dba_users                 c  
  15.          where a.event# = b.event#  
  16.            and a.user_id = c.user_id  
  17.            and sample_time > '21-NOV-04 12:00:00 AM'  
  18.            and sample_time < '21-NOV-04 05:00:00 AM'  
  19.            and b.wait_class = 'User I/O'  
  20.          group by a.session_id,  
  21.                   decode(session_type,  
  22.                          'background',  
  23.                          session_type,  
  24.                          c.username),  
  25.                   a.program,  
  26.                   b.name),  
  27.        (select sum(a.time_waited) total_time  
  28.           from sys.v_$active_session_history a, sys.v_$event_name b  
  29.          where a.event# = b.event#  
  30.            and sample_time > '21-NOV-04 12:00:00 AM'  
  31.            and sample_time < '21-NOV-04 05:00:00 AM'  
  32.            and b.wait_class = 'User I/O')  
  33.  order by 6 desc;  




SQL级别

从ORACLE10g开始以下等待相关的事件列被加入到了session视图中。


  • APPLICATION_WAIT_TIME
  • CONCURRENCY_WAIT_TIME
  • CLUSTER_WAIT_TIME
  • USER_IO_WAIT_TIME
  • PLSQL_EXEC_TIME
  • JAVA_EXEC_TIME

--按照IO等待取top5
[sql]  view plain  copy
 print ?
  1. select *  
  2. from  
  3. (select sql_text,  
  4.         sql_id,  
  5.         elapsed_time,  
  6.         cpu_time,  
  7.         user_io_wait_time  
  8. from    sys.v_$sqlarea  
  9. order by 5 desc)  
  10. where rownum < 6;  

--再次进行下钻获得SQL详细
[sql]  view plain  copy
 print ?
  1. select event,  
  2.         time_waited,  
  3.         owner,  
  4.         object_name,  
  5.         current_file#,  
  6.         current_block#   
  7. from    sys.v_$active_session_history a,  
  8.         sys.dba_objects b   
  9. where   sql_id = '6gvch1xu9ca3g' and  
  10.         a.current_obj# = b.object_id and  
  11.         time_waited <> 0;  


总体来讲,响应时间给了用户更加直观的观察数据库的度量!

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/317034/viewspace-2096871/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/317034/viewspace-2096871/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值