2013年(350)
分类: Oracle
2013-04-27 09:59:32
这项统计专门用来分析某条指定的SQL语句,通过awrsqrpt.sql脚本,能够生成指定sql(曾经执行过的SQL)的执行计划,消耗的资源等等信息,有助于DBA进行SQL调优。
具体操作如下,首先还是执行生成脚本:
SQL> @$ORACLE_HOME/rdbms/admin/awrsqrpt.sql
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
3812548755 TEST08 1 test08
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Would you like an HTML report, or a plain text report?
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'
Enter value for report_type: html选择生成的报表格式,没啥说的,就默认的html格式吧。
Type Specified: html
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 3812548755 1 TEST08 test08 yans1
Using 3812548755 for database Id
Using 1 for instance number
Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed. Pressing
specifying a number lists all completed snapshots.
Enter value for num_days: 2指定报表快照的生成区间!
Listing the last 2 days of Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
test08 TEST08 7450 25 10 月 2009 00:00 1
7451 25 10 月 2009 01:00 1
7452 25 10 月 2009 02:00 1
7453 25 10 月 2009 03:00 1
7454 25 10 月 2009 04:00 1
7455 25 10 月 2009 05:00 1
7456 25 10 月 2009 06:00 1
7457 25 10 月 2009 07:00 1
7458 25 10 月 2009 08:00 1
7459 25 10 月 2009 09:00 1
7460 25 10 月 2009 10:00 1
7461 25 10 月 2009 11:00 1
7462 25 10 月 2009 12:00 1
7463 25 10 月 2009 13:00 1
7464 25 10 月 2009 14:00 1
7465 25 10 月 2009 15:00 1
7466 25 10 月 2009 16:00 1
7467 25 10 月 2009 17:00 1
7468 25 10 月 2009 18:00 1
7469 25 10 月 2009 19:00 1
7470 25 10 月 2009 20:00 1
7471 25 10 月 2009 21:00 1
7472 25 10 月 2009 22:00 1
7473 25 10 月 2009 23:00 1
7474 26 10 月 2009 00:00 1
7475 26 10 月 2009 01:00 1
7476 26 10 月 2009 02:00 1
7477 26 10 月 2009 03:00 1
7478 26 10 月 2009 04:00 1
7479 26 10 月 2009 05:00 1
7480 26 10 月 2009 06:00 1
7481 26 10 月 2009 07:00 1
7482 26 10 月 2009 08:00 1
7483 26 10 月 2009 09:00 1
7484 26 10 月 2009 10:00 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 7451
Begin Snapshot Id specified: 7451
Enter value for end_snap: 7475
End Snapshot Id specified: 7475指定开始和结束的快照ID:
Specify the SQL Id
~~~~~~~~~~~~~~~~~~
Enter value for sql_id: a51q9un8j1kv6注意喽,这里要指定分析的SQL_ID,你可能想问,要分析的SQL ID从何而来呢?一般来说,提出这种问题说明你还未操作过awr或看到一条SQL。为什么这么说呢,因为一般来讲,获取问题SQL的途径要么是通过V$SQL(及其它相关视图),要么是通过AWR/STATSPACK等工具,而这些方式找到SQL语句时,只要你再稍微拿眼神的旁光这么一扫,就会发现在语句的旁边有一条SQL ID静静的矗立着:)
SQL ID specified: a51q9un8j1kv6
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrsqlrpt_1_7451_7475.html. To use this name,
press
Enter value for report_name: awr_sqlrpt_1_7451_7475.html
Using the report name awr_sqlrpt_1_7451_7475.html