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. leetcode 300最长上升子序列

    用递归DFS遍历所有组合肯定积分会超时,原因是有很多重复的操作,可以想象每次回溯后肯定会有重复操作.所以改用动态规划.建立一个vector<int>memo,初始化为1,memo[i]表示 ...

  2. Linux下利用Valgrind工具进行内存泄露检测和性能分析

    from http://www.linuxidc.com/Linux/2012-06/63754.htm Valgrind通常用来成分析程序性能及程序中的内存泄露错误 一 Valgrind工具集简绍 ...

  3. iOS UI基础 - 20 UITextField

    //找到已经创建好的UITextField UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(, , RFS ...

  4. unity3d-知识汇总

    itween下载 http://www.youkexueyuan.com/exp_show/1147.html 代码修改精灵图片的透明度 UIBp.GetComponent<Image>( ...

  5. 使用mysqlbinlog从二进制日志文件中查询mysql执行过的sql语句 (原)

    前提MySQL开启了binlog日志操作1. 查看MySQL是否开启binlog(进mysql操作) mysql> show variables like 'log_bin%';       2 ...

  6. sqli-labs(十六)(order by注入)

    第四十六关: http://www.bubuko.com/infodetail-2481914.html 这有篇文章讲得还不错可以看下 这关是order by后面的一个注入,用报错注入和盲注都是可以的 ...

  7. C++二进制字符串转十六进制字符串 十六进制字符串转二进制字符串

    ============================================== 二进制转十六进制 ============================================ ...

  8. ubuntu 安装/卸载nginx及常用命令

    安装命令 sudo apt-get update #更新apt sudo apt-get install nginx #安装nginx 启动/重启/停止命令 一. /etc/init.d/nginx ...

  9. [7] Windows内核情景分析---线程同步

    基于同步对象的等待.唤醒机制: 一个线程可以等待一个对象或多个对象而进入等待状态(也叫睡眠状态),另一个线程可以触发那个等待对象,唤醒在那个对象上等待的所有线程. 一个线程可以等待一个对象或多个对象, ...

  10. python 将word另存为txt

      import os import os.path from win32com import client as wc c=[] rootdir=["d:/77"] #以该路径为 ...