通过ADDM进行SQL调优
2010-10-27 22:09
148 查看
转自:http://ningzi82.itpub.net/post/12186/507631
declare
l_task_id varchar2(20);
l_sql varchar2(2000);
begin
l_sql := 'SELECT COUNT(*) QTY FROM SFCS_DEFECTS WHERE ORG_ID=:1 AND SN_KEY=:2 and rs_id is null';
dbms_sqltune.drop_tuning_task ('addm');
l_task_id := dbms_sqltune.create_tuning_task (
sql_text => l_sql,
user_name => 'SMP',
scope => 'COMPREHENSIVE',
time_limit => 120,
task_name => 'addm'
);
dbms_sqltune.execute_tuning_task ('addm');
end;
/
set serveroutput on size 999999
set long 999999
select dbms_sqltune.report_tuning_task ('addm') from dual;
实际操作如下:
#################
addm report:
#################
Running the ADDM analysis on the specified pair of snapshots ...
Generating the ADDM report for this analysis ...
DETAILED ADDM REPORT FOR TASK 'TASK_24828' WITH ID 24828
--------------------------------------------------------
Analysis Period: 26-OCT-2010 from 09:00:50 to 10:00:48
Database ID/Instance: 774218943/1
Database/Instance Names: STCSMES/STCSMES
Host Name: stcsmesfab2
Database Version: 10.2.0.4.0
Snapshot Range: from 5399 to 5400
Database Time: 45103 seconds
Average Database Load: 12.5 active sessions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FINDING 1: 72% impact (32345 seconds)
-------------------------------------
Host CPU was a bottleneck and the instance was consuming 47% of the host CPU.
All wait times will be inflated by wait for CPU.
RECOMMENDATION 1: Host Configuration, 58% benefit (26237 seconds)
ACTION: Consider adding more CPUs to the host or adding instances
serving the database on other hosts.
ACTION: Also consider using Oracle Database Resource Manager to
prioritize the workload from various consumer groups.
RECOMMENDATION 2: SQL Tuning, 23% benefit (10494 seconds)
ACTION: Run SQL Tuning Advisor on the SQL statement with SQL_ID
"6u2js5kw4v66k".
RELEVANT OBJECT: SQL statement with SQL_ID 6u2js5kw4v66k and
PLAN_HASH 2068937292
select count(*) cnt from(select sn_key,i_time from SFCS_DEFECTS where
org_id=:1 and sn_key=:2 and rs_id is null group by sn_key,i_time)
ACTION: Investigate the SQL statement with SQL_ID "6u2js5kw4v66k" for
possible performance improvements.
RELEVANT OBJECT: SQL statement with SQL_ID 6u2js5kw4v66k and
PLAN_HASH 2068937292
select count(*) cnt from(select sn_key,i_time from SFCS_DEFECTS where
org_id=:1 and sn_key=:2 and rs_id is null group by sn_key,i_time)
RATIONALE: SQL statement with SQL_ID "6u2js5kw4v66k" was executed 15735
times and had an average elapsed time of 0.65 seconds.
RATIONALE: Average CPU used per execution was 0.26 seconds.
##########################
通过addm进行SQL调优:
##########################
SQL> declare
2 l_task_id varchar2(20);
3 l_sql varchar2(2000);
4 begin
5 l_sql := 'select count(*) cnt from(select sn_key, i_time from SFCS_DEFECTS where org_id=:1 and sn_key=:2 and rs_id is null group by sn_key, i_time)';
6 l_task_id := dbms_sqltune.create_tuning_task (
7 sql_text => l_sql,
8 user_name => 'SMP',
9 scope => 'COMPREHENSIVE',
10 time_limit => 60,
11 task_name => 'addm'
12 );
13 dbms_sqltune.execute_tuning_task ('addm');
14 end;
15 /
PL/SQL procedure successfully completed.
SQL> set serveroutput on size 999999
SQL> set long 999999
SQL> select dbms_sqltune.report_tuning_task ('addm') from dual;
DBMS_SQLTUNE.REPORT_TUNING_TASK('ADDM')
--------------------------------------------------------------------------------
GENERAL INFORMATION SECTION
-------------------------------------------------------------------------------
Tuning Task Name : addm
Tuning Task Owner : SYS
Scope : COMPREHENSIVE
Time Limit(seconds): 60
Completion Status : COMPLETED
Started at : 10/26/2010 13:41:10
Completed at : 10/26/2010 13:41:14
-------------------------------------------------------------------------------
DBMS_SQLTUNE.REPORT_TUNING_TASK('ADDM')
--------------------------------------------------------------------------------
Schema Name: SMP
SQL ID : 78nrgfjx0qkkv
SQL Text : select count(*) cnt from(select sn_key, i_time from SFCS_DEFECTS
where org_id=:1 and sn_key=:2 and rs_id is null group by sn_key,
i_time)
-------------------------------------------------------------------------------
There are no recommendations to improve the statement.
-------------------------------------------------------------------------------
参考网址:
http://www.hellodba.com/Doc/Oracle%2010G_addm_advisor.htm http://space.itpub.net/?uid-12361284-action-viewspace-itemid-164945
declare
l_task_id varchar2(20);
l_sql varchar2(2000);
begin
l_sql := 'SELECT COUNT(*) QTY FROM SFCS_DEFECTS WHERE ORG_ID=:1 AND SN_KEY=:2 and rs_id is null';
dbms_sqltune.drop_tuning_task ('addm');
l_task_id := dbms_sqltune.create_tuning_task (
sql_text => l_sql,
user_name => 'SMP',
scope => 'COMPREHENSIVE',
time_limit => 120,
task_name => 'addm'
);
dbms_sqltune.execute_tuning_task ('addm');
end;
/
set serveroutput on size 999999
set long 999999
select dbms_sqltune.report_tuning_task ('addm') from dual;
实际操作如下:
#################
addm report:
#################
Running the ADDM analysis on the specified pair of snapshots ...
Generating the ADDM report for this analysis ...
DETAILED ADDM REPORT FOR TASK 'TASK_24828' WITH ID 24828
--------------------------------------------------------
Analysis Period: 26-OCT-2010 from 09:00:50 to 10:00:48
Database ID/Instance: 774218943/1
Database/Instance Names: STCSMES/STCSMES
Host Name: stcsmesfab2
Database Version: 10.2.0.4.0
Snapshot Range: from 5399 to 5400
Database Time: 45103 seconds
Average Database Load: 12.5 active sessions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FINDING 1: 72% impact (32345 seconds)
-------------------------------------
Host CPU was a bottleneck and the instance was consuming 47% of the host CPU.
All wait times will be inflated by wait for CPU.
RECOMMENDATION 1: Host Configuration, 58% benefit (26237 seconds)
ACTION: Consider adding more CPUs to the host or adding instances
serving the database on other hosts.
ACTION: Also consider using Oracle Database Resource Manager to
prioritize the workload from various consumer groups.
RECOMMENDATION 2: SQL Tuning, 23% benefit (10494 seconds)
ACTION: Run SQL Tuning Advisor on the SQL statement with SQL_ID
"6u2js5kw4v66k".
RELEVANT OBJECT: SQL statement with SQL_ID 6u2js5kw4v66k and
PLAN_HASH 2068937292
select count(*) cnt from(select sn_key,i_time from SFCS_DEFECTS where
org_id=:1 and sn_key=:2 and rs_id is null group by sn_key,i_time)
ACTION: Investigate the SQL statement with SQL_ID "6u2js5kw4v66k" for
possible performance improvements.
RELEVANT OBJECT: SQL statement with SQL_ID 6u2js5kw4v66k and
PLAN_HASH 2068937292
select count(*) cnt from(select sn_key,i_time from SFCS_DEFECTS where
org_id=:1 and sn_key=:2 and rs_id is null group by sn_key,i_time)
RATIONALE: SQL statement with SQL_ID "6u2js5kw4v66k" was executed 15735
times and had an average elapsed time of 0.65 seconds.
RATIONALE: Average CPU used per execution was 0.26 seconds.
##########################
通过addm进行SQL调优:
##########################
SQL> declare
2 l_task_id varchar2(20);
3 l_sql varchar2(2000);
4 begin
5 l_sql := 'select count(*) cnt from(select sn_key, i_time from SFCS_DEFECTS where org_id=:1 and sn_key=:2 and rs_id is null group by sn_key, i_time)';
6 l_task_id := dbms_sqltune.create_tuning_task (
7 sql_text => l_sql,
8 user_name => 'SMP',
9 scope => 'COMPREHENSIVE',
10 time_limit => 60,
11 task_name => 'addm'
12 );
13 dbms_sqltune.execute_tuning_task ('addm');
14 end;
15 /
PL/SQL procedure successfully completed.
SQL> set serveroutput on size 999999
SQL> set long 999999
SQL> select dbms_sqltune.report_tuning_task ('addm') from dual;
DBMS_SQLTUNE.REPORT_TUNING_TASK('ADDM')
--------------------------------------------------------------------------------
GENERAL INFORMATION SECTION
-------------------------------------------------------------------------------
Tuning Task Name : addm
Tuning Task Owner : SYS
Scope : COMPREHENSIVE
Time Limit(seconds): 60
Completion Status : COMPLETED
Started at : 10/26/2010 13:41:10
Completed at : 10/26/2010 13:41:14
-------------------------------------------------------------------------------
DBMS_SQLTUNE.REPORT_TUNING_TASK('ADDM')
--------------------------------------------------------------------------------
Schema Name: SMP
SQL ID : 78nrgfjx0qkkv
SQL Text : select count(*) cnt from(select sn_key, i_time from SFCS_DEFECTS
where org_id=:1 and sn_key=:2 and rs_id is null group by sn_key,
i_time)
-------------------------------------------------------------------------------
There are no recommendations to improve the statement.
-------------------------------------------------------------------------------
参考网址:
http://www.hellodba.com/Doc/Oracle%2010G_addm_advisor.htm http://space.itpub.net/?uid-12361284-action-viewspace-itemid-164945
相关文章推荐
- Undocumented Way–通过手工创建sql profiles固定执行计划进行SQL调优
- 使用plsql执行计划进行sql调优
- 通过创建GameObject 改变Mesh进行网格绘制
- silverlight 通过WCF与LinQ对数据库进行操作2
- Linux下通过find命令进行rm文件删除的小技巧
- as通过gradle实现多渠道打包+使用配置文件进行版本管理+指定apk输出路径和apk文件名
- 如何通过 TFTP 方式对 WNDR3700 进行固件修复
- Linux下通过mdadm进行软raid设置(rhel6.0)
- Ubuntu通过修改配置文件来进行网络配置
- 通过InputMethodManager对输入法键盘进行关闭
- 原生JS实现Ajax通过GET方式与PHP进行交互操作示例
- 通过调节坐标进行jfree图的放大缩小
- JavaScript通过字典进行字符串翻译转换的方法
- 对原生SQL查询执行的控制是通过SQLQuery接口进行的,通过执行Session.createSQLQuery()
- Windows Git与github通过ssh进行远程协作
- secureCRT通过代理进行ssh连接
- 通过MSSQL把对文件进行修改重命名,并且自动增加流水号
- 通过Spring @PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作
- android---------SurfaceTexture----------通过SurfaceTexture来对预览的图像进行处理
- mssql将传入的文本信息写入临时表,记录之间通过';'进行分割,商品编码,数量,销售金额通过','进行分割