advisor调优工具优化sql(基于sql_id)
问题背景:
客户反馈数据库迁移后cpu负载激增,帮忙查看原因
解决思路:
1> 查看问题系统发现有大量的latch: cache buffers chains 等待;
latch:cache buffers chains出现的原因
1、不够优化的SQL。
大量逻辑读的SQL语句就有可能产生非常严重的latch:cache buffers chains等待,因为每次要访问一个block,
就需要获得该latch,由于有大量的逻辑读,那么就增加了latch:cache buffers chains争用的机率。
对于正在运行的SQL语句,产生非常严重的latch:cache buffers chains争用,可以利用下面SQL查看执行计划,并设法优化SQL语句。
select * from table(dbms_xplan.display_cursor(‘sql_id’,sql_child_number));
如果SQL已经运行完毕,我们就看AWR报表里面的SQL Statistics->SQL ordered by Gets->Gets per Exec,试图优化这些SQL。
2、热点块争用
查找数据库是否存在latch的争用
select sid,event,p1text,p1raw from v$session_wait where event=’latch: cache buffers chains’
首先把DB服务器的cpu降下来,kill latch: cache buffers chains 会话
select ‘alter system kill session ”’ || a.sid || ‘,’ || serial# || ”’;’
from v$session a
where a.username=’USERNAME’
AND a.STATUS=’ACTIVE’
and event in(‘latch: cache buffers chains’,’latch free’)
alter system kill session ‘56,18142’ ;
alter system kill session ‘319,1510’ ;
2> 根据sql_id查看问题sql的执行计划,(有三个执行计划)
SQL> select * from table(dbms_xplan.display_awr(‘&1’));
Enter value for 1: a6su7qgyywvn8
old 1: select * from table(dbms_xplan.display_awr(‘&1’))
new 1: select * from table(dbms_xplan.display_awr(‘a6su7qgyywvn8’))
PLAN_TABLE_OUTPUT
——————————————————————————————————————————————————————————————————–
SQL_ID a6su7qgyywvn8
——————–
Plan hash value: 1019409405
—————————————————————————————————————————
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
—————————————————————————————————————————
| 0 | SELECT STATEMENT | | | | 331 (100)| |
| 1 | VIEW | | 532 | 205K| 331 (1)| 00:00:04 |
| 2 | COUNT | | | | | |
| 3 | VIEW | | 532 | 198K| 331 (1)| 00:00:04 |
| 4 | SORT ORDER BY | | 532 | 192K| 331 (1)| 00:00:04 |
| 5 | COUNT | | | | | |
| 6 | VIEW | | 532 | 192K| 331 (1)| 00:00:04 |
| 7 | HASH UNIQUE | | 532 | 97K| 331 (1)| 00:00:04 |
| 8 | CONCATENATION | | | | | |
| 9 | FILTER | | | | | |
| 10 | NESTED LOOPS | | 1 | 188 | 12 (0)| 00:00:01 |
| 11 | NESTED LOOPS | | 1 | 169 | 11 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 1 | 90 | 10 (0)| 00:00:01 |
| 13 | NESTED LOOPS | | 1 | 84 | 9 (0)| 00:00:01 |
| 14 | INDEX FAST FULL SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 4 (0)| 00:00:01 |
| 15 | INLIST ITERATOR | | | | | |
| 16 | TABLE ACCESS BY INDEX ROWID| WORKFLOW_CURRENTOPERATOR | 1 | 65 | 5 (0)| 00:00:01 |
| 17 | INDEX RANGE SCAN | WRKCUOPER_USER_IN2 | 1 | | 4 (0)| 00:00:01 |
| 18 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_BASE | 1 | 6 | 1 (0)| 00:00:01 |
| 19 | INDEX RANGE SCAN | IX_WFBASE_ID | 1 | | 0 (0)| |
| 20 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_REQUESTBASE | 1 | 79 | 1 (0)| 00:00:01 |
| 21 | INDEX UNIQUE SCAN | WORKFLOW_REQUESTID | 1 | | 0 (0)| |
| 22 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 23 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 2 (0)| 00:00:01 |
| 24 | NESTED LOOPS | | 1 | 35 | 3 (0)| 00:00:01 |
| 25 | MERGE JOIN CARTESIAN | | 1 | 26 | 2 (0)| 00:00:01 |
| 26 | INDEX RANGE SCAN | IX_WORKFLOW_NODEBASE_IDIS | 1 | 7 | 1 (0)| 00:00:01 |
| 27 | BUFFER SORT | | 1 | 19 | 1 (0)| 00:00:01 |
| 28 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 29 | INDEX RANGE SCAN | IX_WKFFLND_NW | 1 | 9 | 1 (0)| 00:00:01 |
| 30 | FILTER | | | | | |
| 31 | NESTED LOOPS | | | | | |
| 32 | NESTED LOOPS | | 1 | 188 | 318 (0)| 00:00:04 |
| 33 | NESTED LOOPS | | 1 | 182 | 317 (0)| 00:00:04 |
| 34 | NESTED LOOPS | | 1 | 163 | 316 (0)| 00:00:04 |
| 35 | NESTED LOOPS | | 1 | 84 | 315 (0)| 00:00:04 |
| 36 | INDEX FAST FULL SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 4 (0)| 00:00:01 |
| 37 | TABLE ACCESS BY INDEX ROWID| WORKFLOW_CURRENTOPERATOR | 7 | 455 | 311 (0)| 00:00:04 |
| 38 | INDEX RANGE SCAN | USERANDREQUESTID | 316 | | 3 (0)| 00:00:01 |
| 39 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_REQUESTBASE | 1 | 79 | 1 (0)| 00:00:01 |
| 40 | INDEX UNIQUE SCAN | WORKFLOW_REQUESTID | 1 | | 0 (0)| |
| 41 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 42 | INDEX RANGE SCAN | IX_WFBASE_ID | 1 | | 0 (0)| |
| 43 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_BASE | 5 | 30 | 1 (0)| 00:00:01 |
| 44 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 2 (0)| 00:00:01 |
| 45 | NESTED LOOPS | | 1 | 35 | 3 (0)| 00:00:01 |
| 46 | MERGE JOIN CARTESIAN | | 1 | 26 | 2 (0)| 00:00:01 |
| 47 | INDEX RANGE SCAN | IX_WORKFLOW_NODEBASE_IDIS | 1 | 7 | 1 (0)| 00:00:01 |
| 48 | BUFFER SORT | | 1 | 19 | 1 (0)| 00:00:01 |
| 49 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 50 | INDEX RANGE SCAN | IX_WKFFLND_NW | 1 | 9 | 1 (0)| 00:00:01 |
—————————————————————————————————————————
Note
—–
– cardinality feedback used for this statement
SQL_ID a6su7qgyywvn8
——————–
Plan hash value: 1061600654
—————————————————————————————————————————
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
—————————————————————————————————————————
| 0 | SELECT STATEMENT | | | | 1507 (100)| |
| 1 | VIEW | | 532 | 205K| 1507 (1)| 00:00:19 |
| 2 | COUNT | | | | | |
| 3 | VIEW | | 532 | 198K| 1507 (1)| 00:00:19 |
| 4 | SORT ORDER BY | | 532 | 192K| 1507 (1)| 00:00:19 |
| 5 | COUNT | | | | | |
| 6 | VIEW | | 532 | 192K| 1507 (1)| 00:00:19 |
| 7 | HASH UNIQUE | | 532 | 97K| 1507 (1)| 00:00:19 |
| 8 | CONCATENATION | | | | | |
| 9 | FILTER | | | | | |
| 10 | NESTED LOOPS | | 1 | 188 | 12 (0)| 00:00:01 |
| 11 | NESTED LOOPS | | 1 | 169 | 11 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 1 | 90 | 10 (0)| 00:00:01 |
| 13 | NESTED LOOPS | | 1 | 84 | 9 (0)| 00:00:01 |
| 14 | INDEX FAST FULL SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 4 (0)| 00:00:01 |
| 15 | INLIST ITERATOR | | | | | |
| 16 | TABLE ACCESS BY INDEX ROWID| WORKFLOW_CURRENTOPERATOR | 1 | 65 | 5 (0)| 00:00:01 |
| 17 | INDEX RANGE SCAN | WRKCUOPER_USER_IN2 | 1 | | 4 (0)| 00:00:01 |
| 18 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_BASE | 1 | 6 | 1 (0)| 00:00:01 |
| 19 | INDEX RANGE SCAN | IX_WFBASE_ID | 1 | | 0 (0)| |
| 20 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_REQUESTBASE | 1 | 79 | 1 (0)| 00:00:01 |
| 21 | INDEX UNIQUE SCAN | WORKFLOW_REQUESTID | 1 | | 0 (0)| |
| 22 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 23 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 2 (0)| 00:00:01 |
| 24 | NESTED LOOPS | | 1 | 35 | 3 (0)| 00:00:01 |
| 25 | MERGE JOIN CARTESIAN | | 1 | 26 | 2 (0)| 00:00:01 |
| 26 | INDEX RANGE SCAN | IX_WORKFLOW_NODEBASE_IDIS | 1 | 7 | 1 (0)| 00:00:01 |
| 27 | BUFFER SORT | | 1 | 19 | 1 (0)| 00:00:01 |
| 28 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 29 | INDEX RANGE SCAN | IX_WKFFLND_NW | 1 | 9 | 1 (0)| 00:00:01 |
| 30 | FILTER | | | | | |
| 31 | NESTED LOOPS | | | | | |
| 32 | NESTED LOOPS | | 1 | 188 | 1494 (1)| 00:00:18 |
| 33 | NESTED LOOPS | | 1 | 182 | 1493 (1)| 00:00:18 |
| 34 | MERGE JOIN CARTESIAN | | 40 | 4680 | 1373 (1)| 00:00:17 |
| 35 | MERGE JOIN CARTESIAN | | 1 | 38 | 5 (0)| 00:00:01 |
| 36 | INDEX FAST FULL SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 4 (0)| 00:00:01 |
| 37 | BUFFER SORT | | 1 | 19 | 1 (0)| 00:00:01 |
| 38 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 39 | BUFFER SORT | | 105K| 8150K| 1372 (1)| 00:00:17 |
| 40 | TABLE ACCESS FULL | WORKFLOW_REQUESTBASE | 105K| 8150K| 1368 (1)| 00:00:17 |
| 41 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_CURRENTOPERATOR | 1 | 65 | 3 (0)| 00:00:01 |
| 42 | INDEX RANGE SCAN | WORKFLOWUSERANDID | 1 | | 2 (0)| 00:00:01 |
| 43 | INDEX RANGE SCAN | IX_WFBASE_ID | 1 | | 0 (0)| |
| 44 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_BASE | 5 | 30 | 1 (0)| 00:00:01 |
| 45 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 2 (0)| 00:00:01 |
| 46 | NESTED LOOPS | | 1 | 35 | 3 (0)| 00:00:01 |
| 47 | MERGE JOIN CARTESIAN | | 1 | 26 | 2 (0)| 00:00:01 |
| 48 | INDEX RANGE SCAN | IX_WORKFLOW_NODEBASE_IDIS | 1 | 7 | 1 (0)| 00:00:01 |
| 49 | BUFFER SORT | | 1 | 19 | 1 (0)| 00:00:01 |
| 50 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 51 | INDEX RANGE SCAN | IX_WKFFLND_NW | 1 | 9 | 1 (0)| 00:00:01 |
—————————————————————————————————————————
Note
—–
– cardinality feedback used for this statement
SQL_ID a6su7qgyywvn8
——————–
Plan hash value: 1147966846
—————————————————————————————————————————
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
—————————————————————————————————————————
| 0 | SELECT STATEMENT | | | | 24 (100)| |
| 1 | VIEW | | 1 | 396 | 24 (5)| 00:00:01 |
| 2 | COUNT | | | | | |
| 3 | VIEW | | 1 | 383 | 24 (5)| 00:00:01 |
| 4 | SORT ORDER BY | | 1 | 370 | 24 (5)| 00:00:01 |
| 5 | COUNT | | | | | |
| 6 | VIEW | | 1 | 370 | 24 (5)| 00:00:01 |
| 7 | HASH UNIQUE | | 1 | 188 | 24 (5)| 00:00:01 |
| 8 | CONCATENATION | | | | | |
| 9 | FILTER | | | | | |
| 10 | NESTED LOOPS | | | | | |
| 11 | NESTED LOOPS | | 1 | 188 | 10 (0)| 00:00:01 |
| 12 | NESTED LOOPS | | 1 | 109 | 9 (0)| 00:00:01 |
| 13 | NESTED LOOPS | | 1 | 103 | 8 (0)| 00:00:01 |
| 14 | MERGE JOIN CARTESIAN | | 1 | 38 | 3 (0)| 00:00:01 |
| 15 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 2 (0)| 00:00:01 |
| 16 | BUFFER SORT | | 1 | 19 | 1 (0)| 00:00:01 |
| 17 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 18 | INLIST ITERATOR | | | | | |
| 19 | TABLE ACCESS BY INDEX ROWID| WORKFLOW_CURRENTOPERATOR | 1 | 65 | 5 (0)| 00:00:01 |
| 20 | INDEX RANGE SCAN | WRKCUOPER_USER_IN2 | 1 | | 4 (0)| 00:00:01 |
| 21 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_BASE | 1 | 6 | 1 (0)| 00:00:01 |
| 22 | INDEX RANGE SCAN | IX_WFBASE_ID | 1 | | 0 (0)| |
| 23 | INDEX UNIQUE SCAN | WORKFLOW_REQUESTID | 1 | | 0 (0)| |
| 24 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_REQUESTBASE | 1 | 79 | 1 (0)| 00:00:01 |
| 25 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 2 (0)| 00:00:01 |
| 26 | NESTED LOOPS | | 1 | 35 | 3 (0)| 00:00:01 |
| 27 | MERGE JOIN CARTESIAN | | 1 | 26 | 2 (0)| 00:00:01 |
| 28 | INDEX RANGE SCAN | IX_WORKFLOW_NODEBASE_IDIS | 1 | 7 | 1 (0)| 00:00:01 |
| 29 | BUFFER SORT | | 1 | 19 | 1 (0)| 00:00:01 |
| 30 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 31 | INDEX RANGE SCAN | IX_WKFFLND_NW | 1 | 9 | 1 (0)| 00:00:01 |
| 32 | FILTER | | | | | |
| 33 | NESTED LOOPS | | | | | |
| 34 | NESTED LOOPS | | 1 | 188 | 13 (0)| 00:00:01 |
| 35 | NESTED LOOPS | | 1 | 109 | 12 (0)| 00:00:01 |
| 36 | NESTED LOOPS | | 1 | 103 | 11 (0)| 00:00:01 |
| 37 | MERGE JOIN CARTESIAN | | 1 | 38 | 3 (0)| 00:00:01 |
| 38 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 2 (0)| 00:00:01 |
| 39 | BUFFER SORT | | 1 | 19 | 1 (0)| 00:00:01 |
| 40 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 41 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_CURRENTOPERATOR | 1 | 65 | 8 (0)| 00:00:01 |
| 42 | INDEX RANGE SCAN | WRKCUOPER_USER_IN2 | 7 | | 2 (0)| 00:00:01 |
| 43 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_BASE | 1 | 6 | 1 (0)| 00:00:01 |
| 44 | INDEX RANGE SCAN | IX_WFBASE_ID | 1 | | 0 (0)| |
| 45 | INDEX UNIQUE SCAN | WORKFLOW_REQUESTID | 1 | | 0 (0)| |
| 46 | TABLE ACCESS BY INDEX ROWID | WORKFLOW_REQUESTBASE | 1 | 79 | 1 (0)| 00:00:01 |
| 47 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 2 (0)| 00:00:01 |
| 48 | NESTED LOOPS | | 1 | 35 | 3 (0)| 00:00:01 |
| 49 | MERGE JOIN CARTESIAN | | 1 | 26 | 2 (0)| 00:00:01 |
| 50 | INDEX RANGE SCAN | IX_WORKFLOW_NODEBASE_IDIS | 1 | 7 | 1 (0)| 00:00:01 |
| 51 | BUFFER SORT | | 1 | 19 | 1 (0)| 00:00:01 |
| 52 | INDEX RANGE SCAN | WORKFLOWCENTERSETTINGDETAIL_I | 1 | 19 | 1 (0)| 00:00:01 |
| 53 | INDEX RANGE SCAN | IX_WKFFLND_NW | 1 | 9 | 1 (0)| 00:00:01 |
—————————————————————————————————————————
270 rows selected.
可以看出执行计划非常糟糕,这次不手工调优,尝试使用advisor工具(基于sql_id)
可以用sql_id创建sql tunning任务,比用sql_text方便很多
FUNCTION CREATE_TUNING_TASK RETURNS VARCHAR2
Argument Name Type In/Out Default?
—————————— ———————– —— ——–
SQL_ID VARCHAR2 IN
PLAN_HASH_VALUE NUMBER IN DEFAULT
SCOPE VARCHAR2 IN DEFAULT
TIME_LIMIT NUMBER IN DEFAULT
TASK_NAME VARCHAR2 IN DEFAULT
DESCRIPTION VARCHAR2 IN DEFAULT
————————————————
DECLARE
my_task_name VARCHAR2(30);
BEGIN
my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
SQL_ID => ‘xxxx’,
scope => ‘COMPREHENSIVE’,
time_limit => 60,
task_name => ‘tunning_task_xxxx’,
description => ‘Task to tune a query on xxxx’);
END;
/
我们查看此时任务的状态
> select task_name,EXECUTION_START,EXECUTION_END,STATUS from DBA_ADVISOR_LOG where task_name like ‘tunning_task_xxxx%’;
TASK_NAME EXECUTION_START EXECUTION_END STATUS
—————————— ——————- ——————- ———–
tunning_task_xxxx INITIAL
执行sql tuning任务
BEGIN
DBMS_SQLTUNE.EXECUTE_TUNING_TASK( task_name => ‘tunning_task_xxxx’ );
END;
/
展示sql tunning结果
SET LONG 10000
SET LONGCHUNKSIZE 1000
SET LINESIZE 100
SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK(‘tunning_task_xxxx’)
FROM DUAL;
调优后
SQL> SET LONG 10000
SQL> SET LONGCHUNKSIZE 1000
SQL> SET LINESIZE 100
SQL> SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK(‘tunning_task_ddw7j6yfnw0vz’)
2 FROM DUAL;
DBMS_SQLTUNE.REPORT_TUNING_TASK(‘TUNNING_TASK_DDW7J6YFNW0VZ’)
—————————————————————————————————-
GENERAL INFORMATION SECTION
——————————————————————————-
Tuning Task Name : tunning_task_ddw7j6yfnw0vz
Tuning Task Owner : USERNAME
Workload Type : Single SQL Statement
Scope : COMPREHENSIVE
Time Limit(seconds): 60
Completion Status : COMPLETED
Started at : 10/24/2019 16:54:27
Completed at : 10/24/2019 16:54:33
——————————————————————————-
Schema Name: USERNAME
SQL ID : a6su7qgyywvn8
SQL Text :
——————————————————————————-
FINDINGS SECTION (3 findings)
——————————————————————————-
1- SQL Profile Finding (see explain plans section below)
——————————————————–
A potentially better execution plan was found for this statement.
Recommendation (estimated benefit: 27.05%)
——————————————
– Consider accepting the recommended SQL profile.
execute dbms_sqltune.accept_sql_profile(task_name =>
‘tunning_task_ddw7j6yfnw0vz’, task_owner => ‘USERNAME’, replace =>
TRUE);
Validation results
——————
The SQL profile was tested by executing both its plan and the original plan
and measuring their respective execution statistics. A plan may have been
only partially executed if the other could be run to completion in less time.
Original Plan With SQL Profile % Improved
————- —————- ———-
Completion Status: COMPLETE COMPLETE
Elapsed Time(us): 61144 61755 -.99 %
CPU Time(us): 21282 20590 3.25 %
User I/O Time(us): 0 0
Buffer Gets: 3062 2233 27.07 %
Physical Read Requests: 0 0
Physical Write Requests: 0 0
Physical Read Bytes: 0 0
Physical Write Bytes: 0 0
Rows Processed: 5 5
Fetches: 5 5
Executions: 1 1
Notes
—–
1. The original plan was first executed to warm the buffer cache.
2. Statistics for original plan were averaged over next 9 executions.
3. The SQL profile plan was first executed to warm the buffer cache.
4. Statistics for the SQL profile plan were averaged over next 9 executions.
2- Index Finding (see explain plans section below)
————————————————–
The execution plan of this statement can be improved by creating one or more
indices.
Recommendation (estimated benefit: 97.87%)
——————————————
– Consider running the Access Advisor to improve the physical schema design
or creating the recommended index.
create index USERNAME.IDX$$_6F3D0001 on
USERNAME.WORKFLOWCENTERSETTINGDETAIL(“EID”,”TYPE”,”TABID”);
– Consider running the Access Advisor to improve the physical schema design
or creating the recommended index.
create index USERNAME.IDX$$_6F3D0002 on
USERNAME.WORKFLOW_CURRENTOPERATOR(“WORKFLOWID”);
Rationale
———
Creating the recommended indices significantly improves the execution plan
of this statement. However, it might be preferable to run “Access Advisor”
using a representative SQL workload as opposed to a single statement. This
will allow to get comprehensive index recommendations which takes into
account index maintenance overhead and additional space consumption.
3- Alternative Plan Finding
—————————
Some alternative execution plans for this statement were found by searching
the system’s real-time and historical performance data.
The following table lists these plans ranked by their average elapsed time.
See section “ALTERNATIVE PLANS SECTION” for detailed information on each
plan.
id plan hash last seen elapsed (s) origin note
— ———- ——————– ———— ————— —————-
1 1019409405 2019-10-24/14:22:29 0.935 Cursor Cache
2 1147966846 2019-10-24/14:14:00 49.312 Cursor Cache
3 1061600654 2019-10-24/14:22:32 7432.859 Cursor Cache
Information
———–
– Because no execution history for the Original Plan was found, the SQL
Tuning Advisor could not determine if any of these execution plans are
superior to it. However, if you know that one alternative plan is better
than the Original Plan, you can create a SQL plan baseline for it. This
will instruct the Oracle optimizer to pick it over any other choices in
the future.
execute dbms_sqltune.create_sql_plan_baseline(task_name =>
‘tunning_task_ddw7j6yfnw0vz’, owner_name => ‘USERNAME’,
plan_hash_value => xxxxxxxx);
——————————————————————————-
ADDITIONAL INFORMATION SECTION
——————————————————————————-
– The optimizer could not merge the view at line ID 6 of the execution plan.
The optimizer cannot merge a complex view if its parent query contains a
reference to a “ROWNUM” pseudo-column.
– The optimizer could not merge the view at line ID 3 of the execution plan.
The optimizer cannot merge a view that contains a “ROWNUM” pseudo column.
– The optimizer could not merge the view at line ID 1 of the execution plan.
The optimizer cannot merge a view that contains a “ROWNUM” pseudo column.
– SQL Profile “SYS_SQLPROF_016dfcf4b7e90000” exists for this statement and
was ignored during the tuning process.
——————————————————————————-
EXPLAIN PLANS SECTION
——————————————————————————-
1- Original With Adjusted Cost
——————————
Plan hash value: 3347560359
—————————————————————————————————-
——————————-
| Id | Operation | Name | Rows | Bytes |T
empSpc| Cost (%CPU)| Time |
—————————————————————————————————-
——————————-
| 0 | SELECT STATEMENT | | 1 | 396 |
| 94499 (1)| 00:18:54 |
|* 1 | VIEW | | 1 | 396 |
| 94499 (1)| 00:18:54 |
| 2 | COUNT | | | |
| | |
| 3 | VIEW | | 1 | 383 |
| 94499 (1)| 00:18:54 |
| 4 | SORT ORDER BY | | 1 | 370 |
| 94499 (1)| 00:18:54 |
| 5 | COUNT | | | |
| | |
| 6 | VIEW | | 1 | 370 |
| 94632 (1)| 00:18:56 |
| 7 | HASH UNIQUE | | 1 | 182 |
| 94632 (1)| 00:18:56 |
| 8 | CONCATENATION | | | |
| | |
|* 9 | FILTER | | | |
| | |
| 10 | NESTED LOOPS | | 37216 | 6614K|
|
根据advisor的建议调整
查看DB服务器负载已经正常,调优成功