ash是非常有效的监控工具之一,1秒抓一次
select max(sample_time)over(),min(sample_time)over() from dba_hist_active_sess_history; --8天
select max(sample_time)over(),min(sample_time)over() from v$active_session_history; --当天
首先先了解几个视图:
V$ACTIVE_SESSION_HISTORY: 是ASH的核心,用以记录活动SESSION的历史等待信息,每秒采样一次,这部分内容记录在内存中,期望值是记录一个小时的内容。
WRH#_ACTIVE_SESSION_HISTORY : 是V$ACTIVE_SESSION_HISTORY在AWR的存储地。
V$ACTIVE_SESSION_HISTORY: 中的信息会被定期(每小时一次)的刷新到负载库中,并缺省保留一个星期用于分析。
DBA_HIST_ACTIVE_SESS_HISTORY: 视图是WRH#_ACTIVE_SESSION_HISTORY视图和其他几个视图的联合展现,通常通过这个视图进行历史数据的访问。
------------------------------------
--V$ACTIVE_SESSION_HISTORY的监控:--
------------------------------------
------------session:1-----------------
SQL> @big
SID
----------
131
Elapsed: 00:00:00.00
drop table big
*
ERROR at line 1:
ORA-00942: table or view does not exist
Elapsed: 00:00:00.03
Elapsed: 00:00:00.31
Elapsed: 00:00:00.34
Elapsed: 00:00:00.29
Elapsed: 00:00:00.73
Elapsed: 00:00:01.75
Elapsed: 00:00:10.59
Elapsed: 00:00:24.62
Elapsed: 00:00:00.01
BIG_M
----------
522
Elapsed: 00:00:00.36
COUNT(*)
----------
4650368
Elapsed: 00:00:26.70
------------session:2-----------------
SQL> @getash_sid
Enter value for sid: 131
SESSION_ID NAME P_NAME P_VALUE SQL_ID WAIT_TIME CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK#
---------- ---------------------------------------------------------------- --------------- --------------- ------------- ---------- ------------ ------------- ---------
131 db file sequential read file# 1 d2wbn28rdk8z4 0 547 1 3604
block# 53206
blocks 1
131 db file sequential read file# 1 d2wbn28rdk8z4 0 -1 0 0
block# 3009
blocks 1
131 db file scattered read file# 4 03b71c07nsc1a 0 134 1 1064
block# 4845
blocks 8
131 log buffer space 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch (che
ckpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch completion 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 6046
0
0
131 db file scattered read file# 4 aq32z6wjx1s4h 0 76851 4 4995
block# 4995
blocks 5
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 7170
0
0
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 7170
0
0
131 db file scattered read file# 4 aq32z6wjx1s4h 0 76851 4 8578
block# 8578
blocks 126
131 db file scattered read file# 4 aq32z6wjx1s4h 0 76851 4 12802
block# 12802
blocks 126
131 log file switch (checkpoint incomplete) 0 aq32z6wjx1s4h 0 76851 4 12930
0
0
131 db file sequential read file# 1 aq32z6wjx1s4h 0 65921 201 3585
block# 2854
blocks 1
131 db file scattered read file# 4 aq32z6wjx1s4h 0 76851 4 14084
block# 14084
blocks 124
131 db file scattered read file# 4 aq32z6wjx1s4h 0 76851 4 18436
block# 18436
blocks 128
131 db file scattered read