透過ADDM進行SQL調優
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;[@more@]
實際操作如下:
#################
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.
-------------------------------------------------------------------------------
參考網址:
%2010G_addm_advisor.htm
http://space.itpub.net/?uid-12361284-action-viewspace-itemid-164945
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/789833/viewspace-1040419/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 通過ADDM進行SQL調優SQL
- 透過AWR REPORT 或 ADDM REPORT進行SQLTUNESQL
- 透過使用hint unnest調優sql語句SQL
- oracle 通過statspace 進行效能調優Oracle
- 透過addm分析io問題
- 大廠是怎麼進行SQL調優的?SQL
- 使用sqld360進行特定SQL調優分析SQL
- 使用SQL調整顧問進行語句優化SQL優化
- Oracle 透過rowid秒優SQLOracleSQL
- 實戰分析Java的非同步程式設計,並透過CompletableFuture進行高效調優Java非同步程式設計
- SQL Server調優系列進階篇(查詢優化器的執行方式)SQLServer優化
- 透過 OKR 進行專案過程管理OKR
- 透過 NTP 進行時鐘同步
- 記一次SQL調優過程SQL
- SQL調優SQL
- 使用SQL Profile進行SQL優化案例SQL優化
- 循序漸進調優union相關的sqlSQL
- 透過.PAC進行網路釣魚
- 透過dns進行檔案下載DNS
- 通過使用hint unnest調優sql語句SQL
- sql調優學習之cpu消耗過多...SQL
- sql調優1SQL
- oracle sql調優OracleSQL
- 透過SQL_ID檢視SQL歷史執行資訊SQL
- 透過案例學調優之--Oracle Time Model(時間模型)Oracle模型
- 如何透過CRM系統進行合同管理?
- 透過寫入實體進行匯出
- 教程直播第7期|如何對 OceanBase 進行 SQL 診斷和調優SQL
- 【sql調優之執行計劃】sort operationsSQL
- 【sql調優之執行計劃】estimator iSQL
- 【sql調優之執行計劃】hash joinSQL
- 通過 HTTP 頭進行 SQL 注入HTTPSQL
- 透過查詢檢視sql執行計劃SQL
- MySQL調優篇 | SQL調優實戰(5)MySql
- 使用dbms_sqltune進行SQL優化SQL優化
- ORACLE sql 語句的執行過程(SQL效能調整)OracleSQL
- Teradata SQL調優SQL
- 如何透過文件協作進行專案管理?專案管理