- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
2#
发表于 2013-3-9 22:14:42
1. AWR、V$都未必是100%精确的
2. 总的来说 dba_hist_sysstat 比 DBA_HIST_SQLSTAT 更适合反应总体的 活动指标
3. 试试下面这个脚本- alter session set nls_date_format='dd-mon-yy';
- set lines 160 pages 1000 echo off feedback off
- col stat_name for a25
- col date_time for a40
- col BEGIN_INTERVAL_TIME for a20
- col END_INTERVAL_TIME for a20
- prompt "Enter the date in DD-Mon-YY Format and Stats you want to trend like 'redo size','physical reads','physical writes','session logical reads' etc."
- WITH sysstat AS
- (select sn.begin_interval_time begin_interval_time,
- sn.end_interval_time end_interval_time,
- ss.stat_name stat_name,
- ss.value e_value,
- lag(ss.value, 1) over(order by ss.snap_id) b_value
- from dba_hist_sysstat ss, dba_hist_snapshot sn
- where trunc(sn.begin_interval_time) >= sysdate-7
- and ss.snap_id = sn.snap_id
- and ss.dbid = sn.dbid
- and ss.instance_number = sn.instance_number
- and ss.dbid = (select dbid from v$database)
- and ss.instance_number = (select instance_number from v$instance)
- and ss.stat_name = 'physical reads')
- select to_char(BEGIN_INTERVAL_TIME, 'mm/dd/yy_hh24_mi') || to_char(END_INTERVAL_TIME, '_hh24_mi') date_time,
- stat_name,
- round((e_value - nvl(b_value,0)) / (extract(day from(end_interval_time - begin_interval_time)) * 24 * 60 * 60
- + extract(hour from(end_interval_time - begin_interval_time)) * 60 * 60
- + extract(minute from(end_interval_time - begin_interval_time)) * 60 + extract(second from(end_interval_time - begin_interval_time))),0) per_sec
- from sysstat where(e_value - nvl(b_value,0)) > 0 and nvl(b_value,0) > 0
- /
复制代码 |
|