4.Accept recommended SQL Profile
SQL> DECLARE
2 my_sqlprofile_name VARCHAR2(30);
3 begin
4 my_sqlprofile_name := DBMS_SQLTUNE.ACCEPT_SQL_PROFILE (
5 task_name => 'my_sql_tuning_task_5',
6 name => 'my_sql_profile5',
7 replace => TRUE,
8 force_match =>TRUE);
9 end;
10 /
PL/SQL procedure successfully completed.
注:如上选项中force_match是强制所有的此类SQL,对于不同的字面值都可以转换成绑定变量,让此类SQL都使用此执行几乎.
再次查询如下sql:
- SQL> l
- 1* select /*+ no_index(test test_idx) */ * from test where n=:v
- SQL> /
- N
- ----------
- 1
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 2882402178
- -----------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- -----------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 1 | 4 | 1 (0)| 00:00:01 |
- |* 1 | INDEX RANGE SCAN| TEST_IDX | 1 | 4 | 1 (0)| 00:00:01 |
- -----------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 1 - access("N"=TO_NUMBER(:V))
- Note
- -----
- - SQL profile "my_sql_profile5" used for this statement
- Statistics
- ----------------------------------------------------------
- 7 recursive calls
- 0 db block gets
- 7 consistent gets
- 1 physical reads
- 0 redo size
- 415 bytes sent via SQL*Net to client
- 415 bytes received via SQL*Net from client
- 2 SQL*Net roundtrips to/from client
- 0 sorts (memory)
- 0 sorts (disk)
- 1 rows processed
Note部分显示使用了sql profile:my_sql_profile5
Note
-----
- SQL profile "my_sql_profile5" used for this statement
还有更多选项和方法可以查看online document,此简单记录之……
