Oracle10g数据库的历史数据机制允许DBA们按时查看对响应时间趋势的分析,这将有助于DBA们确定事务/系统的高峰时期,更好的定位那些拉长批处理周期和ETL作业的进程和SQL语句。
还可以使用如下的查询来迅速查看最新一个小时的信息,看看数据库的总性能如何:
select end_time,value
from sys.v_$sysmetric_history
where metric_name = 'Database CPU Time Ratio'
order by 1;
END_TIME VALUE
2007-1-24 2 3.21949216
2007-1-24 2 3.01443414
2007-1-24 2 9.75636353
2007-1-24 2 9.28581409
2007-1-24 2 43.3490481
2007-1-24 2 38.8366361
2007-1-24 2 32.0272511
2007-1-24 2 0
2007-1-24 2 22.9580733
2007-1-24 2 33.0615102
2007-1-24 2 43.1294933 |
可以从V$SYSMETRIC_SUMMARY视图中获得数据库整体性能效率的最大、最小和平均值:
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')
ORDER BY 1;
METRIC_NAME MININUM MAXIMUM AVERAGE
CPU Usage Per Sec 0 53.9947577 11.1603280
CPU Usage Per Txn 0 168.731666 24.8848615
Database CPU Time Ratio 0 87.1866295 35.8114730
Database Wait Time Ratio 0 90.7141859 64.1885269
Executions Per Sec 0 540.768348 114.852472
Executions Per Txn 0 1911 279.912779
Response Time Per Txn (secs) 0 3.88 0.66
SQL Service Response Time (secs) 0 0 0
User Transaction Per Sec 0 4.70183486 0.94469007 |