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. Git push remote rejected {change ### closed}

    是因为和关掉的提交对应的Change_id一样导致的. 另一种可能是cherry-pick导致的: 之前提交的时候因为有merge,所以在gerrit服务器上审核的时候,我给abandoned了,因此 ...

  2. android studio 设置安装不占用C盘

    我们知道,android studio 安装会占用大量的空间,比如我们我们将andriod status 安装到了D:\IDE\Android Studio这里,但是你会发现,在编译出包过程中,C盘的 ...

  3. 23-Python3 File

    ''' file(文件)方法 ''' #open()对象 pass #file对象 ##file.close():关闭文件,关闭后不能再进行读写操作 fo1 = open('/Users/ligaij ...

  4. [LeetCode] 339. Nested List Weight Sum_Easy tag:DFS

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  5. [LeetCode] 100. Same Tree_Easy tag: DFS

    Given two binary trees, write a function to check if they are the same or not. Two binary trees are ...

  6. jmeter二次开发----Loadrunner或Jmeter发送邮件报告

    Loadrunner支持Java Vuser,而Jmeter本身就是基于Java开发的,所以两者都可以通过JMail组件实现邮件发送.本人使用的是mail-1.4.7.jar,可以通过下载获得:htt ...

  7. springmvc注解式开发

    搭建环境 后端控制器无需实现接口,添加相应的注解 springmvc配置文件中无需注册controller springmvc配置文件中添加组件扫描器.注解驱动 涉及常用的注解 @controller ...

  8. DoTween

    dotween最原始的用法 using System.Collections; using System.Collections.Generic; using UnityEngine; using D ...

  9. Cassandra创建第一个用户

    Cassandra配置文件cassandra.yaml 的配置项, 默认是 authenticator: AllowAllAuthenticator 现在想创建Cassandra的用户,但是如果保持以 ...

  10. Python记录7:函数3,函数对象

    #函数对象指的是:函数的内存地址可以像变量值一样去使用,如何使用?def func(): print('from func')#1. 可以被引用# f=func# print(f)# f() #2. ...