响应时间作为一种数据库性能的度量单位,在以前的版本中很难从数据库角度提取出来,但是从10g之后这样的度量单位变得更为简单。
在过去DBA做性能分析主要依据的指标是响应时间度量和用户活动情况,分析人员所面临的问题就是如果确定应用系统的哪一部分消耗了大部分时间,以及客观的反应用户对系统的使用体验。
OWI的出现犹如横空出世的利器,帮助DBA诊断瓶颈,发现瓶颈。但是OWI还是不能更直观的告诉用户关于活动会话或事物交易能力评估。很幸运的时候10g之后数据库中有关于会话和系统层面的响应时间相关的度量出现了。比如ADDM中有很多FINDING就已经给出官员响应时间的指标。10g提供的历史回溯功能可以更有效的帮助dba对系统过去时刻出现的性能问题做出基于响应时间的趋势分析。
系统级别分析
从全局角度考虑3个问题
- 一般情况我们的数据库运行效率如何,是如何定义效率的呢?
- 我们的用户遭遇了什么样的平均响应时间?
- 系统中那些活动最影响系统的相应时间?
以上的疑问可以在10g中很高的通过METREC来回答。
--查看整体情况
- select METRIC_NAME, VALUE
- from SYS.V_$SYSMETRIC
- where METRIC_NAME IN
- ('Database CPU Time Ratio', 'Database Wait Time Ratio')
- AND INTSIZE_CSEC = (select max(INTSIZE_CSEC) from SYS.V_$SYSMETRIC);
--查看最近一小时的
- select to_char(end_time,'hh24:mi:ss'), value
- from sys.v_$sysmetric_history
- where metric_name = 'Database CPU Time Ratio'
- order by 1;
--总体上 最大,最小,平均
- select CASE METRIC_NAME
- WHEN 'SQL Service Response Time' then
- 'SQL Service Response Time (secs)'
- WHEN 'Response Time Per Txn' then
- 'Response Time Per Txn (secs)'
- ELSE
- METRIC_NAME
- END METRIC_NAME,
- CASE METRIC_NAME
- WHEN 'SQL Service Response Time' then
- ROUND((MINVAL / 100), 2)
- WHEN 'Response Time Per Txn' then
- ROUND((MINVAL / 100), 2)
- ELSE
- MINVAL
- END MININUM,
- CASE METRIC_NAME
- WHEN 'SQL Service Response Time' then
- ROUND((MAXVAL / 100), 2)
- WHEN 'Response Time Per Txn' then
- ROUND((MAXVAL / 100), 2)
- ELSE
- MAXVAL
- END MAXIMUM,
- CASE METRIC_NAME
- WHEN 'SQL Service Response Time' then
- ROUND((AVERAGE / 100), 2)
- WHEN 'Response Time Per Txn' then
- ROUND((AVERAGE / 100), 2)
- ELSE
- AVERAGE
- END AVERAGE
- from SYS.V_$SYSMETRIC_SUMMARY
- where METRIC_NAME in
- ('CPU Usage Per Sec', 'CPU Usage Per Txn', 'Database CPU Time Ratio',
- 'Database Wait Time Ratio', 'Executions Per Sec',
- 'Executions Per Txn', 'Response Time Per Txn',
- 'SQL Service Response Time', 'User Transaction Per Sec');
--可以从时间模型角度分析
- select case db_stat_name
- when 'parse time elapsed' then
- 'soft parse time'
- else
- db_stat_name
- end db_stat_name,
- case db_stat_name
- when 'sql execute elapsed time' then
- time_secs - plsql_time
- when 'parse time elapsed' then
- time_secs - hard_parse_time
- else
- time_secs
- end time_secs,
- case db_stat_name
- when 'sql execute elapsed time' then
- round(100 * (time_secs - plsql_time) / db_time, 2)
- when 'parse time elapsed' then
- round(100 * (time_secs - hard_parse_time) / db_time, 2)
- else
- round(100 * time_secs / db_time, 2)
- end pct_time
- from (select stat_name db_stat_name, round((value / 1000000), 3) time_secs
- from sys.v_$sys_time_model
- where stat_name not in ('DB time', 'background elapsed time',
- 'background cpu time', 'DB CPU')),
- (select round((value / 1000000), 3) db_time
- from sys.v_$sys_time_model
- where stat_name = 'DB time'),
- (select round((value / 1000000), 3) plsql_time
- from sys.v_$sys_time_model
- where stat_name = 'PL/SQL execution elapsed time'),
- (select round((value / 1000000), 3) hard_parse_time
- from sys.v_$sys_time_model
- where stat_name = 'hard parse elapsed time')
- order by 2 desc;
--从event class角度了解系统
- select to_char(a.end_time, 'DD-MON-YYYY HH:MI:SS') end_time,
- b.wait_class,
- round((a.time_waited / 100), 2) time_waited
- from sys.v_$waitclassmetric_history a, sys.v_$system_wait_class b
- where a.wait_class# = b.wait_class#
- and b.wait_class != 'Idle'
- order by 1, 2
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/317034/viewspace-2096869/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/317034/viewspace-2096869/