使用 DBMS_WORKLOAD_REPOSITORY 包管理 baseline
1. 创建 baseline
--在 DBA_HIST_SNAPSHOT 视图中查看现有的快照来确定要使用的快照范围。
select snap_id,dbid,BEGIN_INTERVAL_TIME,END_INTERVAL_TIME,SNAP_LEVEL from dba_hist_snapshot;
SNAP_ID DBID BEGIN_INTERVAL_TIME END_INTERVAL_TIME SNAP_LEVEL
---------- ---------- ------------------------------ ------------------------------ ----------
21 220853307 04-MAR-13 02.00.49.845 PM 04-MAR-13 03.00.58.970 PM 1
22 220853307 04-MAR-13 03.00.58.970 PM 04-MAR-13 04.00.08.328 PM 1
23 220853307 04-MAR-13 04.00.08.328 PM 04-MAR-13 05.00.17.091 PM 1
24 220853307 04-MAR-13 05.00.17.091 PM 04-MAR-13 06.00.26.037 PM 1
25 220853307 04-MAR-13 06.00.26.037 PM 04-MAR-13 07.00.35.429 PM 1
26 220853307 04-MAR-13 07.00.35.429 PM 04-MAR-13 08.00.44.059 PM 1
27 220853307 06-MAR-13 10.30.05.000 PM 06-MAR-13 10.40.56.516 PM 1
28 220853307 07-MAR-13 09.08.50.000 PM 07-MAR-13 09.19.47.771 PM 1
29 220853307 07-MAR-13 09.19.47.771 PM 07-MAR-13 10.00.53.958 PM 1
30 220853307 07-MAR-13 10.00.53.958 PM 07-MAR-13 10.59.09.642 PM 1
31 220853307 07-MAR-13 10.59.09.642 PM 08-MAR-13 12.00.13.313 AM 1
32 220853307 08-MAR-13 10.20.00.000 AM 08-MAR-13 10.30.57.436 AM 1
--使用 CREATE_BASELINE 存储过程创建一个 baseline。
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE(
start_snap_id IN NUMBER,
end_snap_id IN NUMBER,
baseline_name IN VARCHAR2,
更多精彩内容:http://www.bianceng.cn/database/Oracle/
dbid IN NUMBER DEFAULT NULL,
expiration IN NUMBER DEFAULT NULL);
BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE (start_snap_id => 21,
end_snap_id => 25, baseline_name => 'peak baseline',
dbid => 220853307, expiration => 30);
END;
/
--21 是起始的 snapshot 序列号,25 是结束 snapshot 序列号。expiration => 30 表示该 baseline 将在30天
--后自动删除
--创建 baseline 时,系统会自动分配一个唯一的 baseline ID 给新建的 baseline。可以通过 DBA_HIST_BASELINE 视图查看。
select dbid,baseline_id,baseline_name,EXPIRATION,CREATION_TIME from dba_hist_baseline;
DBID BASELINE_ID BASELINE_NAME EXPIRATION CREATION_TIME
---------- ----------- -------------------- ---------- -------------------
220853307 1 peak baseline 30 2013-03-08 11:03:03
220853307 0 SYSTEM_MOVING_WINDOW 2013-03-02 14:23:12
2.删除 baseline
BEGIN
DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE (baseline_name => 'peak baseline',