oracle 响应时间分析 (一)

响应时间作为一种数据库性能的度量单位,在以前的版本中很难从数据库角度提取出来,但是从10g之后这样的度量单位变得更为简单。


在过去DBA做性能分析主要依据的指标是响应时间度量和用户活动情况,分析人员所面临的问题就是如果确定应用系统的哪一部分消耗了大部分时间,以及客观的反应用户对系统的使用体验。



OWI的出现犹如横空出世的利器,帮助DBA诊断瓶颈,发现瓶颈。但是OWI还是不能更直观的告诉用户关于活动会话或事物交易能力评估。很幸运的时候10g之后数据库中有关于会话和系统层面的响应时间相关的度量出现了。比如ADDM中有很多FINDING就已经给出官员响应时间的指标。10g提供的历史回溯功能可以更有效的帮助dba对系统过去时刻出现的性能问题做出基于响应时间的趋势分析。

系统级别分析


从全局角度考虑3个问题


  1. 一般情况我们的数据库运行效率如何,是如何定义效率的呢?
  2. 我们的用户遭遇了什么样的平均响应时间?
  3. 系统中那些活动最影响系统的相应时间?


以上的疑问可以在10g中很高的通过METREC来回答。



--查看整体情况

[sql]  view plain  copy
 print ?
  1. select METRIC_NAME, VALUE  
  2.   from SYS.V_$SYSMETRIC  
  3.  where METRIC_NAME IN  
  4.        ('Database CPU Time Ratio''Database Wait Time Ratio')  
  5.    AND INTSIZE_CSEC = (select max(INTSIZE_CSEC) from SYS.V_$SYSMETRIC);  

--查看最近一小时的


[sql]  view plain  copy
 print ?
  1. select to_char(end_time,'hh24:mi:ss'), value  
  2.   from sys.v_$sysmetric_history  
  3.  where metric_name = 'Database CPU Time Ratio'  
  4.  order by 1;  
--总体上 最大,最小,平均
[sql]  view plain  copy
 print ?
  1. select CASE METRIC_NAME  
  2.          WHEN 'SQL Service Response Time' then  
  3.           'SQL Service Response Time (secs)'  
  4.          WHEN 'Response Time Per Txn' then  
  5.           'Response Time Per Txn (secs)'  
  6.          ELSE  
  7.           METRIC_NAME  
  8.        END METRIC_NAME,  
  9.        CASE METRIC_NAME  
  10.          WHEN 'SQL Service Response Time' then  
  11.           ROUND((MINVAL / 100), 2)  
  12.          WHEN 'Response Time Per Txn' then  
  13.           ROUND((MINVAL / 100), 2)  
  14.          ELSE  
  15.           MINVAL  
  16.        END MININUM,  
  17.        CASE METRIC_NAME  
  18.          WHEN 'SQL Service Response Time' then  
  19.           ROUND((MAXVAL / 100), 2)  
  20.          WHEN 'Response Time Per Txn' then  
  21.           ROUND((MAXVAL / 100), 2)  
  22.          ELSE  
  23.           MAXVAL  
  24.        END MAXIMUM,  
  25.        CASE METRIC_NAME  
  26.          WHEN 'SQL Service Response Time' then  
  27.           ROUND((AVERAGE / 100), 2)  
  28.          WHEN 'Response Time Per Txn' then  
  29.           ROUND((AVERAGE / 100), 2)  
  30.          ELSE  
  31.           AVERAGE  
  32.        END AVERAGE  
  33.   from SYS.V_$SYSMETRIC_SUMMARY  
  34.  where METRIC_NAME in  
  35.        ('CPU Usage Per Sec''CPU Usage Per Txn''Database CPU Time Ratio',  
  36.         'Database Wait Time Ratio''Executions Per Sec',  
  37.         'Executions Per Txn''Response Time Per Txn',  
  38.         'SQL Service Response Time''User Transaction Per Sec');  

--可以从时间模型角度分析
[sql]  view plain  copy
 print ?
  1. select case db_stat_name  
  2.          when 'parse time elapsed' then  
  3.           'soft parse time'  
  4.          else  
  5.           db_stat_name  
  6.        end db_stat_name,  
  7.        case db_stat_name  
  8.          when 'sql execute elapsed time' then  
  9.           time_secs - plsql_time  
  10.          when 'parse time elapsed' then  
  11.           time_secs - hard_parse_time  
  12.          else  
  13.           time_secs  
  14.        end time_secs,  
  15.        case db_stat_name  
  16.          when 'sql execute elapsed time' then  
  17.           round(100 * (time_secs - plsql_time) / db_time, 2)  
  18.          when 'parse time elapsed' then  
  19.           round(100 * (time_secs - hard_parse_time) / db_time, 2)  
  20.          else  
  21.           round(100 * time_secs / db_time, 2)  
  22.        end pct_time  
  23.   from (select stat_name db_stat_name, round((value / 1000000), 3) time_secs  
  24.           from sys.v_$sys_time_model  
  25.          where stat_name not in ('DB time''background elapsed time',  
  26.                 'background cpu time''DB CPU')),  
  27.        (select round((value / 1000000), 3) db_time  
  28.           from sys.v_$sys_time_model  
  29.          where stat_name = 'DB time'),  
  30.        (select round((value / 1000000), 3) plsql_time  
  31.           from sys.v_$sys_time_model  
  32.          where stat_name = 'PL/SQL execution elapsed time'),  
  33.        (select round((value / 1000000), 3) hard_parse_time  
  34.           from sys.v_$sys_time_model  
  35.          where stat_name = 'hard parse elapsed time')  
  36.  order by 2 desc;  

--从event class角度了解系统
[sql]  view plain  copy
 print ?
  1. select to_char(a.end_time, 'DD-MON-YYYY HH:MI:SS') end_time,  
  2.        b.wait_class,  
  3.        round((a.time_waited / 100), 2) time_waited  
  4.   from sys.v_$waitclassmetric_history a, sys.v_$system_wait_class b  
  5.  where a.wait_class# = b.wait_class#  
  6.    and b.wait_class != 'Idle'  
  7.  order by 1, 2  

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值