advisor调优工具优化sql(基于sql_id)
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服务器负载已经正常,调优成功
advisor调优工具优化sql(基于sql_id)的更多相关文章
- OCM_第十四天课程:Section6 —》数据库性能调优_各类索引 /调优工具使用/SQL 优化建议
注:本文为原著(其内容来自 腾科教育培训课堂).阅读本文注意事项如下: 1:所有文章的转载请标注本文出处. 2:本文非本人不得用于商业用途.违者将承当相应法律责任. 3:该系列文章目录列表: 一:&l ...
- Oracle第二话之调优工具
Oracle第二话之调优工具 原创if 0 = -I can 发布于2019-04-09 19:53:12 阅读数 172 收藏 展开 目录 1.告警日志 2.用户进程trace文件 3.动态性能视 ...
- JVM性能调优(4) —— 性能调优工具
前序文章: JVM性能调优(1) -- JVM内存模型和类加载运行机制 JVM性能调优(2) -- 垃圾回收器和回收策略 JVM性能调优(3) -- 内存分配和垃圾回收调优 一.JDK工具 先来看看有 ...
- JVM活学活用——调优工具
概述 工具做为图形化界面来展示更能直观的发现问题,另一方面一些耗费性能的分析(dump文件分析)一般也不会在生产直接分析,往往dump下来的文件达1G左右,人工分析效率较低,因此利用工具来分析jvm相 ...
- Kafka性能调优 - Kafka优化的方法
今天,我们将讨论Kafka Performance Tuning.在本文“Kafka性能调优”中,我们将描述在设置集群配置时需要注意的配置.此外,我们将讨论Tuning Kafka Producers ...
- JVM调优工具锦囊
Arthas线上 分析诊断调优工具 以前我们要排查线上问题,通常使用的是jdk自带的调优工具和命令.最常见的就是dump线上日志,然后下载到本地,导入到jvisualvm工具中.这样操作有诸多不变,现 ...
- JVM调优工具使用手册
作为Java开发人员,我们肯定知道JDK的bin目录下有"java.exe"."javac.exe"这两个命令工具,这也是我们平时用得最多的工具.但其实bi ...
- 【原】Learning Spark (Python版) 学习笔记(三)----工作原理、调优与Spark SQL
周末的任务是更新Learning Spark系列第三篇,以为自己写不完了,但为了改正拖延症,还是得完成给自己定的任务啊 = =.这三章主要讲Spark的运行过程(本地+集群),性能调优以及Spark ...
- Android系统性能调优工具介绍
http://blog.csdn.net/innost/article/details/9008691 经作者授权,发表Tieto某青年牛的一篇<程序员>大作. Android系统性能调优 ...
随机推荐
- 编写自动匹配的下拉框(已解决IE8兼容)
如何制作一个带匹配功能的下拉框? 之前看见layui有相关组件,但是发现,如果输入的内容在下拉框中没有相应的匹配,就会清空当前值,搞得我很不满意.有些代码是从网上扒下来的,但是找不到原地址了,凑合看吧 ...
- Linux 笔记 - 第十四章 LAMP 之(一) 环境搭建
博客地址:http://www.moonxy.com 一.前言 LAMP 是 Linux Apache MySQL PHP 的简写,即把 Apache.MySQL 以及 PHP 安装在 Linux 系 ...
- Linux 中 Xampp 的 https 安全证书配置
博客地址:http://www.moonxy.com 一.前言 HTTP 协议是不加密传输数据的,也就是用户跟你的网站之间传递数据有可能在途中被截获,破解传递的真实内容,所以使用不加密的 HTTP 的 ...
- 字符串之————图文讲解字符串排序(LSD、MSD)
本篇文章围绕字符串排序的核心思想,通过图示例子和代码分析的方式讲解了两个经典的字符串排序方法,内容很详细,完整代码放在文章的最后. 一.键索引计数法 在一般排序中,都要用里面的元素不断比较,而字符串这 ...
- 【教程】Bluestacks0.7.9.860以上版3分钟教你摇一摇
Bluestacks 0.7.9.860 版或以上 , 打开文件夹Win 7 用户 : C:\ProgramData\Bluestacks\UserData\InputMapperWin XP 用户 ...
- Vue学习之vue中的v-if,v-show,v-for
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- ELK搭建实时日志分析平台
ELK搭建实时日志分析平台 导言 ELK由ElasticSearch.Logstash和Kiabana三个开源工具组成,ELK平台可以同时实现日志收集.日志搜索和日志分析的功能.对于生产环境中海量日志 ...
- ELK7.3实战安装配置文档
整体架构 一:环境准备 1.环境规划准备 192.168.43.16 jdk,elasticsearch-master ,logstash,kibana 192.168.43.17 jdk,ela ...
- SpringBoot进阶教程(六十二)整合Kafka
在上一篇文章<Linux安装Kafka>中,已经介绍了如何在Linux安装Kafka,以及Kafka的启动/关闭和创建发话题并产生消息和消费消息.这篇文章就介绍介绍SpringBoot整合 ...
- centos 7 常用yum源配置
使用centos系统最熟悉的莫过于yum命令,yum命令可以让安装软件变得那么简单,编译安装的依赖关系大部分都会解决. 工具/原料 centos 7 wget yum 方法/步骤 什么是y ...