[转帖]Active Session History (ASH)

active,session,history,ash · 浏览次数 : 0

小编点评

**Introduction** The article provides an overview of the Active Session History (ASH) in Oracle Database 10g and its use in Enterprise Manager. **What is ASH?** ASH is a tool that provides real-time and historical performance information about Oracle database sessions. It is used to troubleshoot performance issues and identify bottlenecks. **Key Points** * ASH is a sample of a sample, representing a subset of the actual data. * The DBA_HIST_ACTIVE_SESS_HISTORY view is used to access historical ASH data. * Enterprise Manager provides performance pages and the ASH Viewer tool for viewing ASH data. * ASH reports can be generated directly in Enterprise Manager or SQL Developer. **Benefits of Using ASH** * Provides insights into database performance. * Helps identify performance bottlenecks. * Can be used to troubleshoot issues. * Provides historical data for analysis. **How to Access ASH** * The ASH Report and ASH Viewer tools are available in Enterprise Manager. * SQL Developer 4 onward allows viewing ASH reports directly. * For older versions, connect using the "Standard" connection and use the ASH Viewer tool. **Additional Notes** * ASH is supported on Oracle 8i and later versions. * The sample time in the DBA_HIST_ACTIVE_SESS_HISTORY view can be specified in different units. * ASH reports can be generated for specific database instances or all instances.

正文

 

Related articles.

Introduction

For a long time DBAs have been encouraged to use variations on the YAPP method of performance tuning, which focuses on wait event monitoring, rather than hit ratios. Tools like StatspackAWRADDM and SQL Trace are all very useful for gathering wait event information during tuning, but they tend to focus on looking back at what has happened, rather than what is currently happening. The [G]V$ dynamic performance views provide masses of real-time information, but it can be difficult for beginners and experienced people alike to make good use of this information.

Oracle 10g introduced the Active Session History (ASH) as part of the Diagnostics and Tuning Pack. It samples information from the [G]V$ views allowing you to see current and historical information about active sessions on the database.

 Being part of the Diagnostics and Tuning Pack means ASH is only available as a paid option on top of Oracle Database Enterprise Edition.

V$ACTIVE_SESSION_HISTORY

Samples of wait event information are taken once per second and made available using the V$ACTIVE_SESSION_HISTORY view. An active session is one that is waiting on CPU or any event that does not belong to the "Idle" wait class at the time of the sample. The sample information is written to a circular buffer in the SGA, so the greater the database activity, the less time the information will remain available for.

The V$ACTIVE_SESSION_HISTORY view is essentially a fact table, which can be linked to a number of dimensions to provide statistics specific to a variety of things including SQL statements, execution plans, objects, wait events, sessions, modules, actions, client identifiers, services and consumer groups etc. This makes it an incredibly flexible way of identifying what active sessions are doing, or have done. For example, if I wanted to see the main activity on the database for the last 5 minutes, I could use the following query.

SELECT NVL(a.event, 'ON CPU') AS event,
       COUNT(*) AS total_wait_time
FROM   v$active_session_history a
WHERE  a.sample_time > SYSDATE - 5/(24*60) -- 5 mins
GROUP BY a.event
ORDER BY total_wait_time DESC;

EVENT                                                            TOTAL_WAIT_TIME
---------------------------------------------------------------- ---------------
db file sequential read                                                      750
log file parallel write                                                       43
log file sync                                                                 42
db file parallel read                                                         32
control file sequential read                                                  22
ON CPU                                                                        21
db file parallel write                                                        21
log file switch (private strand flush incomplete)                              8
Disk file operations I/O                                                       1
control file parallel write                                                    1
buffer busy waits                                                              1

11 rows selected.

SQL>

Notice how the count of the samples is used to determine the time waited, not the WAIT_TIME or TIME_WAITED columns. Why is this done? Remember, this is sample data, so wait times are accumulating with each sample. Merely summing them will give a falsely high value. To explain this, imagine simplified case where a single session is waiting on "db file sequential read" for 5 seconds. That means we would have 5 samples, that may look like this.

EVENT                   SAMPLE_ID TIME_SEC
======================= ========= ========
db file sequential read         1        1
db file sequential read         2        2
db file sequential read         3        3
db file sequential read         4        4
db file sequential read         5        5

We know the total wait time is 5 seconds. If we count the number of samples, we get 5, which we equate to 5 seconds. If we sum the time for all 5 samples get 15 seconds.

The time columns in the ASH data are a little more complicated than they first appear, so check the documentation when using them. Incorrect usage of these columns is probably the most common mistake people make when using ASH views.

The fact ASH uses samples can of course mean certain bits of information slip through the net, but this is not really a problem. The chances are your main concerns will be those sessions or statements that are taking lots of time. The longer things take to run, the more samples they are likely to be picked up in. It is unlikely that anything of major concern will completely fail to register in the ASH views, but that doesn't mean you can ignore its limitations.

DBA_HIST_ACTIVE_SESS_HISTORY

To allow for historical access to the ASH data, one in ten samples are persisted to disk and made available using the DBA_HIST_ACTIVE_SESS_HISTORY view. So this is a sample of a sample. Using this view is similar to using the V$ACTIVE_SESSION_HISTORY view, but remember the sample time is now 10 seconds, so use (count*10) to measure time, rather than just the count.

SELECT NVL(a.event, 'ON CPU') AS event,
       COUNT(*)*10 AS total_wait_time
FROM   dba_hist_active_sess_history a
WHERE  a.sample_time > SYSDATE - 1 
GROUP BY a.event
ORDER BY total_wait_time DESC;

EVENT                                                            TOTAL_WAIT_TIME
---------------------------------------------------------------- ---------------
db file sequential read                                                     3860
ON CPU                                                                      1500
control file sequential read                                                 990
direct path read temp                                                        580
direct path read                                                             560
log file parallel write                                                      280
db file parallel write                                                       270
Disk file operations I/O                                                     240
log file switch completion                                                   150
log file sync                                                                130
db file parallel read                                                        130
.
.
.

26 rows selected.

SQL>

Enterprise Manager Performance Pages

Accessing the ASH information directly can be very useful, but there are a number of more efficient ways to get to some of this information. The performance pages of Enterprise Manager (Grid Control and Cloud Control) are fantastic. They are based on the ASH information, giving you easy access to real-time and historical performance information.

The following picture is an example of the Enterprise Manager performance home page.

Performance Home

An example of the Top activity page is shown below.

Top Activity

ASH Report

 

ASH reports can be displayed using Enterprise Manager, or generated from SQL*Plus. To manually generate them using SQL*Plus, run the following script, while logged in as a privileged user.

$ORACLE_HOME/rdbms/admin/ashrpt.sql

The script prompts you for the following details:

  • Report Type: [ html | text ]
  • Instance number: [all | n ] - On single instance databases, this defaults to "1". On RAC databases you can report on a specific instance number or "all" instances.
  • Begin Time: The script describes the formats for this value. It can be an explicit date string or an offset of the current datetime. The default is -15 minutes.
  • Duration: The number of minutes to report on. The default duration is (SYSDATE - begin_time).
  • Report Name: A default name is provided. Change this if required.

The script produces either text or HTML output as requested. Examples of these are shown below.

Depending on the options selected, the ASH report scripts call one of several table functions from the DBMS_WORKLOAD_REPOSITORY package.

  • ASH_REPORT_TEXT
  • ASH_REPORT_HTML
  • ASH_GLOBAL_REPORT_TEXT
  • ASH_GLOBAL_REPORT_HTML

SQL Developer and ASH Reports

If you are using SQL Developer 4 onward, you can view ASH reports directly from SQL Developer. If it is not already showing, open the DBA pane "View > DBA", expand the connection of interest, then expand the "Performance" node. The ASH reports are available from the "ASH Reports Viewer" node.

SQL Developer - ASH Report

ASH Viewer

The ASH Viewer tool gives a graphical view of active session history data within the Oracle instance. Interestingly, it is supports Oracle 8i onward. In releases prior to Oracle 10g, or if you don't have a Diagnostic and Tuning Pack license, you can connect using the "Standard" connection and the tool will mimic the functionality of ASH. If you have the necessary licenses, you can make "Enterprise" connections, which use ASH to provide the data.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.

与[转帖]Active Session History (ASH)相似的内容:

[转帖]Active Session History (ASH)

Introduction V$ACTIVE_SESSION_HISTORY DBA_HIST_ACTIVE_SESS_HISTORY Enterprise Manager Performance Pages ASH Report SQL Developer and ASH Reports ASH V

[转帖]ASH、AWR、ADDM区别联系

概念知识梳理 >>根据时段区间生成ASH报告: >>ASH报告信息: ASH (Active Session History) ASH以V$SESSION为基础,每秒采样一次,记录活动会话等待的事件。不活动的会话不会采样,采样工作由新引入的后台进程MMNL来完成。 ASH buffers 的最小值为

[转帖]Redis 4.0 自动内存碎片整理(Active Defrag)源码分析

阅读本文前建议先阅读此篇博客: Redis源码从哪里读起 Redis 4.0 版本增加了许多不错的新功能,其中自动内存碎片整理功能 activedefrag 肯定是非常诱人的一个,这让 Redis 集群回收内存碎片相比 Redis 3.0 更加优雅,便利。我们升级 Redis 4.0 后直接开启了a

[转帖]如何通过dba_hist_active_sess_history分析数据库历史性能问题

https://www.cnblogs.com/DataArt/p/10018932.html 在数据库运行的过程中,我们有时会碰到数据库hung住的问题,在这个时候很多人会选择尽快让它恢复正常而不是找出问题的root cause. 只有在问题被解决后,才意识到需要找到root cause来避免再次

[转帖]记druid 连接池没满,但超时问题 GetConnectionTimeoutException active 5, maxActive 100

记druid 连接池没满,但超时问题 GetConnectionTimeoutException active 5, maxActive 100 问题说明 线上服务突然出现报错,通过日志查找发现是因为服务升级导致压力集中到某个节点上,出现连接获取超时导致的。 从日志中也找到了异常。 异常信息: co

【转帖】Linux 系统双网卡绑定 bond的7种模式

第一种模式:mod=0 ,即:(balance-rr) Round-robin policy(平衡抡循环策略)第二种模式:mod=1,即: (active-backup) Active-backup policy(主-备份策略)第三种模式:mod=2,即:(balance-xor) XOR poli

[转帖]总结:SpringBoot启动参数配置

一、背景 由于项目中加了bootstrap.properties文件,且文件中有变量,如spring.cloud.config.profile=${spring.profiles.active},而bootstrap.properties读取的优先级高于application.properties,

[转帖]jmeter学习笔记(二十二)——监听器插件之jp@gc系列

一、jp@gc - Actiive Threads Over Time 不同时间活动用户数量展示 下面是一个阶梯加压测试的图标 二、jp@gc - Transactions per Second ,即TPS:每秒事务数 性能测试中,最重要的2个指标之一。该插件的作用是在测试脚本执行过程中,监控查看服

[转帖]

Linux ubuntu20.04 网络配置(图文教程) 因为我是刚装好的最小系统,所以很多东西都没有,在开始配置之前需要做下准备 环境准备 系统:ubuntu20.04网卡:双网卡 网卡一:供连接互联网使用网卡二:供连接内网使用(看情况,如果一张网卡足够,没必要做第二张网卡) 工具: net-to

[转帖]

https://cloud.tencent.com/developer/article/2168105?areaSource=104001.13&traceId=zcVNsKTUApF9rNJSkcCbB 前言 Redis作为高性能的内存数据库,在大数据量的情况下也会遇到性能瓶颈,日常开发中只有时刻