exec dbms_workload_repository.create_snapshot();--调用MMON进程立即收集快照

生成AWR报告
@?/rdbms/admin/awrrpt.sql;

9.4.2  SQL语句级AWR报告分析

上面提到还有一个awrsqrpt.sql,它不是为整个实例生成报告,而是为某个特定SQL生成报告,这在优化某些特定SQL时可以隔离掉其他干扰因素,更易量化。如下:

SQL> @awrsqrpt.sql

Current Instance

~~~~~~~~~~~~~~~~

DB Id    DB Name     Inst Num Instance

----------- ------------ -------- ------------

83642957 ORA11G               1 ora11g

…此处快照开始和结束ID选择省去…

Specify the SQL Id

~~~~~~~~~~~~~~~~~~

Enter value for SQL_id: 8rmfvr1sw2wgn       #SQL_ID需要先从V$SQL.sql_ID获取

SQL ID specified:  8rmfvr1sw2wgn

Specify the Report Name

~~~~~~~~~~~~~~~~~~~~~~~

The default report file name is awrsqlrpt_1_2327_2354.html.  To use this name,

press <return> to continue, otherwise enter an alternative.

Enter value for report_name:

Using the report name awrsqlrpt_1_2327_2354.html

执行完成后,当前目录下会生成awrsqlrpt_1_2327_2354.html这个文件。

9.4.5  ASH分析

和AWR一样,ASH也是实时收集,并定期保存到V$动态性能视图中,用户可以通过查询动态视图或者ASH报告进行分析。Oracle会每秒对所有活跃会话(是指正在使用CPU或者等待非空闲事件的会话)进行一次采样,记录其当前等待的事件,该信息被存储SGA的ASH Buffer中,默认大小为32M,对应性能试图是V$ACTIVE_SESSION_HISTORY,并定期刷新到磁盘中,对应性能试图是DBA_HIST_ACTIVE_SESS_HISTORY。ASH中收集的信息包括会话当前正在执行的SQL以及执行计划,访问的对象信息比如对象号、文件号、块号,等待事件及其参数及其他信息。类似于AWR报告,一般通过ashrpt.sql或ashrpti.sql生成ASH报告,ashrpt生成的是整个实例的活动会话报告,ashrpti则是交互式的允许用户指定各种例如比如特定会话、特定SQL、特定模块等,和AWR不同,实例范围的ASH报告用的并不是很多,所以我们以ashrpti.sql生成特定会话的ASH为例。其生成如下:

[oracle@hs-test-10-20-30-14 ~]$ cd /u01/app/Oracle/product/11.2.0/dbhome_1/rdbms/admin/

[oracle@hs-test-10-20-30-14 admin]$ sqlplus "/as sysdba"

SQL> @ashrpti

…此处省区非必要信息…

ASH Samples in this Workload Repository schema

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Oldest ASH sample available:  24-Oct-18 09:00:06   [  14629 mins in the past]

Latest ASH sample available:  03-Nov-18 12:48:12   [      1 mins in the past]

Specify the timeframe to generate the ASH report

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter begin time for report:

--    Valid input formats:

--       To specify absolute begin time:

--         [MM/DD[/YY]] HH24:MI[:SS]

--         Examples: 02/23/03 14:30:15

--                    02/23 14:30:15

--                    14:30:15

--                    14:30

--       To specify relative begin time: (start with '-' sign)

--         -[HH24:]MI

--         Examples: -1:15  (SYSDATE - 1 Hr 15 Mins)

--                    -25    (SYSDATE - 25 Mins)

Defaults to -15 mins

Enter value for begin_time:

Report begin time specified:

Enter duration in minutes starting from begin time:

Defaults to SYSDATE - begin_time

Press Enter to analyze till current time

Enter value for duration:

Report duration specified:

Using 03-Nov-18 12:33:55 as report begin time

Using 03-Nov-18 12:48:58 as report end time

Specify Slot Width (using ashrpti.sql) for 'Activity Over Time' section

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- Explanation:

--   In the 'Activity Over Time' section of the ASH report,

--   the analysis period is divided into smaller slots

--   and top wait events are reported in each of those slots.

-- Default:

--   The analysis period will be automatically split upto 10 slots

--   complying to a minimum slot width of

--     1 minute,  if the source is V$ACTIVE_SESSION_HISTORY or

--     5 minutes, if the source is DBA_HIST_ACTIVE_SESS_HISTORY.

Specify Slot Width in seconds to use in the 'Activity Over Time' section:

Defaults to a value as explained above:

Enter value for slot_width: 10

Slot Width specified: 10

Specify Report Targets (using ashrpti.sql) to generate the ASH report

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- Explanation:

--   ASH Report can accept "Report Targets",

--   like a particular SQL statement, or a particular SESSION,

--   to generate the report on. If one or more report targets are

--   specified, then the data used to generate the report will only be

--   the ASH samples that pertain to ALL the specified report targets.

-- Default:

--   If none of the report targets are specified,

--   then the target defaults to all activity in the database instance.

Specify SESSION_ID (eg: from V$SESSION.SID) report target:

Defaults to NULL:

Enter value for target_session_id: 1144

SESSION report target specified: 1144

Summary of All User Input

-------------------------

Format             : HTML

DB Id                : 83642957

Inst num       : 1

Begin time     : 03-Nov-18 12:33:55

End time       : 03-Nov-18 12:48:58

Slot width     : 10 seconds

Report targets : 1

Report name    : ashrpt_1_1103_1248.html

抓取awr、语句级awr、ashrpt的更多相关文章

  1. tcpdump抓取mysql语句

    抓包工具tcpdump的使用,抓取具体的sql语句 [root@test7_chat_api_im ~]# tcpdump -s -l - |strings tcpdump: listening on ...

  2. mysql perl 抓取update语句

    <pre name="code" class="html"><pre name="code" class="ht ...

  3. sqlserver 抓取所有执行语句 SQL语句分析 死锁 抓取

    原文:sqlserver 抓取所有执行语句 SQL语句分析 死锁 抓取 在多人开发中最头疼的是人少事多没有时间进行codereview,本来功能都没时间写,哪有时间来开会细细来分析代码.软件能跑就行, ...

  4. tcpdump来抓取执行的sql语句

    # tcpdump -n -nn -tttt -i eth1 -s 65535 'port 3306' -w tcpdump_mysql.ret -C 100 一个TCP包中包含多个mysql协议包, ...

  5. 抓取锁的sql语句-第七次修改

    最近闲来没事,把之前写的那个抓取锁的存储过程重新修改.优化了一下,呵呵 create or replace procedure solve_lock_061203_wanjie(v_msg out v ...

  6. 抓取锁的sql语句-第六次修改

    增加异常处理 CREATE OR REPLACE PROCEDURE SOLVE_LOCK AS V_SQL VARCHAR2(3000); --定义 v_sql 接受抓取锁的sql语句V_SQL02 ...

  7. 抓取锁的sql语句-第五次修改

    CREATE OR REPLACE PROCEDURE SOLVE_LOCK AS V_SQL VARCHAR2(3000); --定义 v_sql 接受抓取锁的sql语句V_SQL02 VARCHA ...

  8. 抓取锁的sql语句-第四次修改

    --完成情况   变量V_BLOCKING_SID 用来动态抓取 产生锁的会话id,输出参数没有任何问题,但是执行报错  标识符无效! CREATE OR REPLACE PROCEDURE SOLV ...

  9. 抓取锁的sql语句-第三次修改

    CREATE OR REPLACE PROCEDURE SOLVE_LOCK AS V_SQL VARCHAR2(3000); --定义 v_sql 接受抓取锁的sql语句CUR_LOCK SYS_R ...

随机推荐

  1. 配置opensips经验总结

    主要参考https://www.cnblogs.com/Forever-Kenlen-Ja/p/7741776.html (ubuntu),还有https://blog.csdn.net/sunyun ...

  2. iOS UI基础-9.2 UITableView 简单微博列表

    概述 我们要实现的效果: 这个界面布局也是UITableView实现的,其中的内容就是UITableViewCell,只是这个UITableViewCell是用户自定义实现的.虽然系统自带的UITab ...

  3. 数据加密之SymmetricAlgorithm加密

    #region SymmetricAlgorithm加密 /// <summary> /// 按指定对称算法.键和向量加密字符串 /// </summary> public s ...

  4. phpstudy一系列安装问题

    phpStudy是一款PHP调试环境的程序集成包,该程序包集成最新的Apache+PHP+MySQL+phpMyAdmin+ZendOptimizer,一次性安装,无须配置即可使用,是非常方便.好用的 ...

  5. Hibernate框架的第四天

    ## Hibernate框架的第四天 ## ---------- **回顾:Hibernate框架的第三天** 1. 一对多关联关系映射 * JavaBean的编写 * 编写映射的配置文件 * 使用级 ...

  6. mysql常用参数监控

      1.系统mysql的进程数 ps -ef | grep "mysql" | grep -v "grep" | wc –l 2.Slave_running m ...

  7. jar包的读取

    昨天在做项目插件的时候,因为会用到jar包中的一个文件来初始化程序.并且以后还是会访问这个文件,所以就想到干脆吧文件拷贝到指定目录.在拷贝的时候也费了好一会时间,这里涉及到了jar文件的操作,在这里记 ...

  8. C# Mongo Client 2.4.2判断是否存在表

    public async Task<bool> CollectionExistsAsync(string collectionName) { var filter = new BsonDo ...

  9. c# Mongodb批量更新

    public void Put(List<OnlineItem> datas)         {             try             {                ...

  10. install apache-activemq

    进入bin/linux-x86-64下 cd apache-activemq-5.14.1/bin/linux-x86-64/ 启动 ./activemq start 五.启动成功后,访问 activ ...