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. CI持续集成系统环境--Gitlab+Gerrit+Jenkins完整对接

    原文地址https://www.cnblogs.com/kevingrace/p/5651447.html 近年来,由于开源项目.社区的活跃热度大增,进而引来持续集成(CI)系统的诞生,也越发的听到更 ...

  2. iOS 测试企业应用的分发

    开发者能够方便地来做iOS应用的测试分发,目前可以选用“浦公英”和“Fir.im”来做. 生成IPA文件 生成应用的 IPA 文件可以使用命令行 xcodebuild exportArchive -e ...

  3. EF There is already an open DataReader associated with this Command

    捕捉到 System.InvalidOperationException _HResult=-2146233079 _message=意外的连接状态.在使用包装提供程序时,请确保在已包装的 DbCon ...

  4. ProxySQL(读写分离)部署

    proxySQL是MySQL的中间件产品,是灵活强大的代理层,实现读写分离,支持Query路由功能,支持动态指定某个SQL进行缓存,支持动态加载配置,故障切换和一些SQL 过滤功能 环境: 192.1 ...

  5. Installshield2015 定制安装在C:\Program files 目录 不正确问题

    情境描述:安装时,选择定制安装,安装目录选择C:\Program Files,安装后文件并没有到C:\Program Files,而是安装到了C:\Program Files (x86)目录下. 原因 ...

  6. HDU 2254 奥运(矩阵+二分等比求和)

    奥运 [题目链接]奥运 [题目类型]矩阵+二分等比求和 &题解: 首先离散化城市,之后就是矩阵快速幂了,但让求的是A^(t1)+A^(t1+1)+...+A^(t2),我先想的是打表,但时间真 ...

  7. ArrayList与List性能测试

    理论:由于ArrayList存储数据存在装箱(读取数据存在拆箱),而泛型List<T>直接对T类型数据进行存储,不存在装箱与拆箱拆箱操作,理论上速度应该快一些. 废话少说,上代码. pub ...

  8. php高并发,大流量

    一般使用LVS+PHP集群(1000台),就算日均80亿次请求,每秒有10万并发,那分到每台机器的请求只有100个.只要你的PHP程序不是太差,100QPS总没问题吧? 而真正的瓶颈在于数据库和存储系 ...

  9. 即时通信系统中实现聊天消息加密,让通信更安全【低调赠送:C#开源即时通讯系统(支持广域网)——GGTalk4.5 最新源码】

    在即时通讯系统(IM)中,加密重要的通信消息,是一个常见的需求.尤其在一些政府部门的即时通信软件中(如税务系统),对即时聊天消息进行加密是非常重要的一个功能,因为谈话中可能会涉及到机密的数据.我在最新 ...

  10. 【Hbase学习之四】Hbase表设计案例

    环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk8 hadoop-2.6.5 hbase-0.98.12.1-h ...