范围包括:
系统级,会话级,sql语句级,segments,services
通常,你查看自己感兴趣的累积统计数据在一个周期内的变化情况来确定性能问题。统计信息的数据是通过动态性能视图来进行收集的,
所以当数据库shutdown时这些数据将被重置。为此oracle用 Automatic Workload Repository (AWR) 来保存所有范围(除了session级)
的大部分累积统计信息。
The Automatic Workload Repository (AWR) automatically persists the cumulative and delta values for most of the statistics at all levels except the session level.
Automatic Workload Repository (AWR) 介绍:
AWR收集,处理,维护累积性能统计信息是为了发现性能问题和优化性能。这些数据都在内存中并被保存在数据库中。所以这些数据可以被
显示在动态性能视图和报表中。AWR统计的数据有:
1:对数据库段对象的所有访问和使用统计信息。
2:基于使用在活动上的时间(cpu等等) 和 被显示在视图 V$SYS_TIME_MODEL and V$SESS_TIME_MODEL中的时间模型统计信息。
3:视图V$SYSSTAT and V$SESSTAT中关于系统和session的统计信息
4:产生高的系统负载(基于elapsed time和CPU time参数来衡量)的sql语句
5:最近的历史会话统计信息(ASH)
默认情况下AWR每小时收集一次统计信息并保留8天的数据,AWR收集数据库统计信息这个功能是启用的,它被初始化参数statistics_level控制。该参数默认值为typical,也是官方推荐的设置
设置为all时,会加重DB负载。设置为basic会禁用掉一些新特性,当然此时你可以用DBMS_WORKLOAD_REPOSITORY包来手动收集统计信息。
典型的是60秒。一些metric的数据也会被保存到AWR中。
A metric is another type of statistic collected by Oracle Database.
A metric is defined as the rate of change in some cumulative statistic.
That rate can be measured against a variety of units, including time, transactions, or database calls.
For example, the number database calls per second is a metric.
Metric values are exposed in some V$ views, where the values are the average over a fairly small time interval,
typically 60 seconds. A history of recent metric values is available through V$ views,
and some data is also persisted by AWR snapshots.
的抽样统计信息数据。这些数据被收集到内存中,然后有AWR的进程写入到AWR并持久存储。
Active Session History(ASH) 介绍
V$ACTIVE_SESSION_HISTORY提供了实例中活动会话的抽样数据。活动会话每秒都被抽样并且将抽样数据存储在SGA中的circular buffer中,
任何连接到数据库的会话并且正在等待 一个非空闲等待事件的 会话被定义为活动会话,活动会话还包括抽样的时间点在cpu上(运行)的会话。
V$ACTIVE_SESSION_HISTORY的每一行对应一个活动会话的采样数据,视图返回的第一行为最后一个活动会话的抽样数据,因为这些数据是存放在
SGA中的circular buffer中,所以很依赖于数据系统的活动情况。当系统活动量大时,内存中的抽样数据就少,反之成立。在一个繁忙的系统中
该视图会变得相当大,所以内存中的数据只有一部分被刷新到AWR中存储。
由于只捕获活动会话产生的数据集,该数据集表示的大小是直接关系到被执行的会话,而不是系统允许的一些会话。通过查看V$ACTIVE_SESSION_HISTORY和DBA_HIST_ACTIVE_SESS_HISTORY
你可以检查并进行详细的分析当前的数据和历史的数据。这样可以避免为了收集更多的性能跟踪统计信息而进行的重演工作负载。
Using ASH enables you to examine and perform detailed analysis on both current data in the V$ACTIVE_SESSION_HISTORY view and historical data in the DBA_HIST_ACTIVE_SESS_HISTORY view, often avoiding the need to replay the workload to gather additional performance tracing information.
ASH还支持活动的DG中的物理,逻辑实例和ASM实例。但是这些数据被搜集和展示在V$ACTIVE_SESSION_HISTORY 中,而不会写入到磁盘
Active session history sampling is also available for Active Data Guard physical standby instances and Oracle Automatic Storage Management (Oracle ASM) instances. On these instances, the current session activity is collected and displayed in the V$ACTIVE_SESSION_HISTORY view, but not written to disk.
数据库性能不好的时候可以和statistical baseline做比较从而快速的定位问题。因此,在建立statistical baseline时,要充分考虑采集周期
和数据库负载能不能反应你数据库的峰值。