Oracle-AWR管理包DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS

简介: Oracle-AWR管理包DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS

概述


官方说明:DBMS_WORKLOAD_REPOSITORY

Overview of the Automatic Workload Repository

AWR机制:通过对系统整体动态采样收集快照信息,存储在SYSAUX表空间,,MMON进程实施,快照分析后写入DBA_HIST_%开头的数据字典。

select table_name from dictionary where table_name like 'DBA_HIST_%';

DBMS_WORKLOAD_REPOSITORY包管理AWR(Automatic Workload Repository),执行诸如管理快照和基线等操作。


20180401132207841.png


因包中功能众多,这里我们仅关注MODIFY_SNAPSHOT_SETTINGS


MODIFY_SNAPSHOT_SETTINGS Procedures


201804011323419.png


默认快照间隔1小时,10g保存7天,11g保存8天

可以通过dbms_workload_repository.MODIFY_SNAPSHOT_SETTINGS存过来调整AWR快照的相关参数

我们来看下Oralce对这段存过标注的注释 ,说明均在注释里,请仔细阅读

 --
  -- modify_snapshot_settings()
  -- Procedure to adjust the settings of the snapshot collection.
  --
  -- Input arguments:
  --   retention                - new retention time (in minutes). The
  --                              specified value must be in the range:
  --                              MIN_RETENTION (1 day) to
  --                              MAX_RETENTION (100 years)
  --
  --                              If ZERO is specified, snapshots will be
  --                              retained forever. A large system-defined
  --                              value will be used as the retention setting.
  --
  --                              If NULL is specified, the old value for
  --                              retention is preserved.
  --
  --                              ***************
  --                               NOTE: The retention setting must be
  --                                     greater than or equal to the window
  --                                     size of the 'SYSTEM_MOVING_WINDOW'
  --                                     baseline.  If the retention needs
  --                                     to be less than the window size,
  --                                     the 'modify_baseline_window_size'
  --                                     routine can be used to adjust the
  --                                     window size.
  --                              ***************
  --
  --   interval                 - the interval between each snapshot, in
  --                              units of minutes. The specified value
  --                              must be in the range:
  --                              MIN_INTERVAL (10 minutes) to
  --                              MAX_INTERVAL (100 years)
  --
  --                              If ZERO is specified, automatic and manual
  --                              snapshots will be disabled.  A large
  --                              system-defined value will be used as the
  --                              interval setting.
  --
  --                              If NULL is specified, the
  --                              current value is preserved.
  --
  --   topnsql (NUMBER)         - Top N SQL size.  The number of Top SQL
  --                              to flush for each SQL criteria
  --                              (Elapsed Time, CPU Time, Parse Calls,
  --                               Shareable Memory, Version Count).
  --
  --                              The value for this setting will be not
  --                              be affected by the statistics/flush level
  --                              and will override the system default
  --                              behavior for the AWR SQL collection.  The
  --                              setting will have a minimum value of 30
  --                              and a maximum value of 50000.
  --
  --                              IF NULL is specified, the
  --                              current value is preserved.
  --
  --   topnsql (VARCHAR2)       - Users are allowed to specify the following
  --                              values: ('DEFAULT', 'MAXIMUM', 'N')
  --
  --                              Specifying 'DEFAULT' will revert the system
  --                              back to the default behavior of Top 30 for
  --                              level TYPICAL and Top 100 for level ALL.
  --
  --                              Specifying 'MAXIMUM' will cause the system
  --                              to capture the complete set of SQL in the
  --                              cursor cache.  Specifying the number 'N' is
  --                              equivalent to setting the Top N SQL with
  --                              the NUMBER type.
  --
  --                              Specifying 'N' will cause the system
  --                              to flush the Top N SQL for each criteria.
  --                              The 'N' string is converted into the number
  --                              for Top N SQL.
  --
  --   dbid                     - database identifier for the database to
  --                              adjust setting. If NULL is specified, the
  --                              local dbid will be used.
  --
  --  For example, the following statement can be used to set the
  --  Retention and Interval to their minimum settings:
  --
  --    dbms_workload_repository.modify_snapshot_settings
  --              (retention => DBMS_WORKLOAD_REPOSITORY.MIN_RETENTION
  --               interval  => DBMS_WORKLOAD_REPOSITORY.MIN_INTERVAL)
  --
  --  The following statement can be used to set the Retention to
  --  8 days and the Interval to 60 minutes and the Top N SQL to
  --  the default setting:
  --
  --    dbms_workload_repository.modify_snapshot_settings
  --              (retention => 11520, interval  => 60, topnsql => 'DEFAULT');
  --
  --  The following statement can be used to set the Top N SQL
  --  setting to 200:
  --    dbms_workload_repository.modify_snapshot_settings
  --              (topnsql => 200);
  --


存过定义如下

  PROCEDURE modify_snapshot_settings(retention  IN NUMBER DEFAULT NULL,
                                     interval   IN NUMBER DEFAULT NULL,
                                     topnsql    IN NUMBER DEFAULT NULL,
                                     dbid       IN NUMBER DEFAULT NULL
                                     );
  PROCEDURE modify_snapshot_settings(retention  IN NUMBER   DEFAULT NULL,
                                     interval   IN NUMBER   DEFAULT NULL,
                                     topnsql    IN VARCHAR2,
                                     dbid       IN NUMBER   DEFAULT NULL
                                     );


如何修改默认的参数值呢?


This example changes the interval setting to one hour and the retention setting to two weeks for the local database:

EXECUTE DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(
  interval  =>  60,
  retention =>  20160);


重新查询 DBA_HIST_WR_CONTROL 可以发现新的规则已经生效。

AWR参数存放的表 DBA_HIST_WR_CONTROL

snapshot的信息存放在DBA_HIST_SNAPSHOT


相关文章
|
6月前
|
Oracle Java 关系型数据库
实时计算 Flink版产品使用合集之在同步Oracle数据时,需要下载并添加到项目中的jar包主要包括哪些
实时计算Flink版作为一种强大的流处理和批处理统一的计算框架,广泛应用于各种需要实时数据处理和分析的场景。实时计算Flink版通常结合SQL接口、DataStream API、以及与上下游数据源和存储系统的丰富连接器,提供了一套全面的解决方案,以应对各种实时计算需求。其低延迟、高吞吐、容错性强的特点,使其成为众多企业和组织实时数据处理首选的技术平台。以下是实时计算Flink版的一些典型使用合集。
|
Oracle 关系型数据库 Linux
使用rpm包在Linux上安装Oracle软件和创建数据库
在Linux上安装Oracle软件的过程相当复杂,让很多初学者望而却步。但在Oracle 18c以后Oracle推出了使用rpm包安装Oracle数据库软件的安装方式,安装两个(预安装包和数据库安装包)rpm包即可完成整个Oracle数据库软件的安装。
352 0
使用rpm包在Linux上安装Oracle软件和创建数据库
|
存储 Oracle 关系型数据库
Oracle优化07-分析及动态采样-DBMS_STATS 包
Oracle优化07-分析及动态采样-DBMS_STATS 包
133 0
Oracle优化07-分析及动态采样-DBMS_STATS 包
|
Java Maven
解决maven无法下载oracle.jar包的问题
解决maven无法下载oracle.jar包的问题
274 0
解决maven无法下载oracle.jar包的问题
|
Oracle 关系型数据库 Linux
Docker中使用rpm包的方式安装Oracle 19c
Docker中使用rpm包的方式安装Oracle 19c
541 0
Docker中使用rpm包的方式安装Oracle 19c
|
SQL 存储 Oracle
Oracle恢复方法(表、包)
Oracle恢复方法(表、包)
362 0
Oracle恢复方法(表、包)
|
存储 SQL Oracle
Oracle存储过程、包详解
Oracle存储过程、包详解
314 0