optimizer_index_caching和optimizer_index_cost_adj两个参数说明
OPTIMIZER_INDEX_COST_ADJ
Property | Description |
---|---|
Parameter type | Integer |
Default value | 100 |
Modifiable | ALTER SESSION, ALTER SYSTEM |
Range of values | 1 to 10000 |
OPTIMIZER_INDEX_COST_ADJ lets you tune optimizer behavior for access path selection to be more or less index friendly—that is, to make the optimizer more or less prone to selecting an index access path over a full table scan.
The default for this parameter is 100 percent, at which the optimizer evaluates index access paths at the regular cost. Any other value makes the optimizer evaluate the access path at that percentage of the regular cost. For example, a setting of 50 makes the index access path look half as expensive as normal.
Note:
The adjustment does not apply to user-defined cost functions for domain indexes.See Also:
Oracle Database Performance Tuning Guide for more information on setting this parameter, and on its relationship to "OPTIMIZER_INDEX_CACHING"OPTIMIZER_INDEX_CACHING
Property | Description |
---|---|
Parameter type | Integer |
Default value | 0 |
Modifiable | ALTER SESSION, ALTER SYSTEM |
Range of values | 0 to 100 |
OPTIMIZER_INDEX_CACHING lets you adjust the behavior of cost-based optimization to favor nested loops joins and IN-list iterators.
The cost of executing an index using an IN-list iterator or of executing a nested loops join when an index is used to access the inner table depends on the caching of that index in the buffer cache. The amount of caching depends on factors that the optimizer cannot predict, such as the load on the system and the block access patterns of different users.
You can modify the optimizer's assumptions about index caching for nested loops joins and IN-list iterators by setting this parameter to a value between 0 and 100 to indicate the percentage of the index blocks the optimizer should assume are in the cache. Setting this parameter to a higher value makes nested loops joins and IN-list iterators look less expensive to the optimizer. As a result, it will be more likely to pick nested loops joins over hash or sort-merge joins and to pick indexes using IN-list iterators over other indexes or full table scans. The default for this parameter is 0, which results in default optimizer behavior.
Table created.
SQL > create index t_idx on t(rn);
Index created.
SQL > BEGIN
2
3 DBMS_STATS.GATHER_TABLE_STATS(OWNNAME = > 'SYS' ,
4 TABNAME = > 'T' ,
5 ESTIMATE_PERCENT = > 30 ,
6 METHOD_OPT = > 'FOR ALL COLUMNS SIZE 1' ,
7 NO_INVALIDATE = > FALSE ,
8 CASCADE = > TRUE ,
9 DEGREE = > 4 );
10 END ;
11 /
PL / SQL procedure successfully completed.
SQL > explain plan for select * from t where rn < 200 ;
Explained.
SQL > select * from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan hash value : 470836197
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 0 | SELECT STATEMENT | | 199 | 4179 | 3 ( 0 )| 00:00: 35 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 199 | 4179 | 3 ( 0 )| 00:00: 35 |
| * 2 | INDEX RANGE SCAN | T_IDX | 199 | | 2 ( 0 )| 00:00: 24 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Predicate Information (identified by operation id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 - access ( "RN" < 200 )
14 rows selected.
SQL > alter session set optimizer_index_cost_adj = 50 ;
Session altered.
SQL > explain plan for select * from t where rn < 200 ;
Explained.
SQL > select * from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan hash value : 470836197
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 0 | SELECT STATEMENT | | 199 | 4179 | 2 ( 0 )| 00:00: 18 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 199 | 4179 | 2 ( 0 )| 00:00: 18 |
| * 2 | INDEX RANGE SCAN | T_IDX | 199 | | 1 ( 0 )| 00:00: 12 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Predicate Information (identified by operation id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 - access ( "RN" < 200 )
14 rows selected.
SQL > alter session set optimizer_index_cost_adj = 500 ;
Session altered.
SQL > explain plan for select * from t where rn < 200 ;
Explained.
SQL > select * from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan hash value : 1601196873
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 0 | SELECT STATEMENT | | 199 | 4179 | 6 ( 0 )| 00: 01 : 10 |
| * 1 | TABLE ACCESS FULL | T | 199 | 4179 | 6 ( 0 )| 00: 01 : 10 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Predicate Information (identified by operation id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 - filter( "RN" < 200 )
13 rows selected.
SQL > explain plan for select * from t where rn in ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 100 , 130 , 200 , 240 , 2000 );
Explained.
SQL > select * from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan hash value : 3506647781
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 0 | SELECT STATEMENT | | 12 | 252 | 4 ( 0 )| 00:00: 43 |
| 1 | INLIST ITERATOR | | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| T | 12 | 252 | 4 ( 0 )| 00:00: 43 |
| * 3 | INDEX RANGE SCAN | T_IDX | 12 | | 3 ( 0 )| 00:00: 31 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Predicate Information (identified by operation id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3 - access ( "RN" = 1 OR "RN" = 2 OR "RN" = 3 OR "RN" = 4 OR "RN" = 5 OR "RN" = 6 OR
"RN" = 7 OR "RN" = 100 OR "RN" = 130 OR "RN" = 200 OR "RN" = 240 OR "RN" = 2000 )
16 rows selected.
SQL > alter session set optimizer_index_caching = 10 ;
Session altered.
SQL > explain plan for select * from t where rn in ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 100 , 130 , 200 , 240 , 2000 );
Explained.
SQL > select * from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan hash value : 3506647781
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 0 | SELECT STATEMENT | | 12 | 252 | 3 ( 0 )| 00:00: 31 |
| 1 | INLIST ITERATOR | | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| T | 12 | 252 | 3 ( 0 )| 00:00: 31 |
| * 3 | INDEX RANGE SCAN | T_IDX | 12 | | 2 (0) | 00:00: 19 | --可以看到cost确实降低了
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Predicate Information (identified by operation id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3 - access ( "RN" = 1 OR "RN" = 2 OR "RN" = 3 OR "RN" = 4 OR "RN" = 5 OR "RN" = 6 OR
"RN" = 7 OR "RN" = 100 OR "RN" = 130 OR "RN" = 200 OR "RN" = 240 OR "RN" = 2000 )
16 rows selected
Explained.
SQL > select * from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan hash value : 752965310
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 0 | SELECT STATEMENT | | 1 | 42 | 8 ( 0 )| 00: 01 : 34 |
| 1 | NESTED LOOPS | | | | | |
| 2 | NESTED LOOPS | | 1 | 42 | 8 ( 0 )| 00: 01 : 34 |
| * 3 | TABLE ACCESS FULL | T | 1 | 21 | 6 ( 0 )| 00: 01 : 10 |
| * 4 | INDEX RANGE SCAN | T_IDX | 1 | | 1 ( 0 )| 00:00: 12 |
| 5 | TABLE ACCESS BY INDEX ROWID| T | 1 | 21 | 2 ( 0 )| 00:00: 24 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Predicate Information (identified by operation id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3 - filter( "B" . "NAME" = 'sss' )
4 - access ( "A" . "RN" = "B" . "RN" )
18 rows selected.
SQL > alter session set optimizer_index_caching = 10 ;
Session altered.
SQL > explain plan for select / * + use_nl(a b) * / * from t a,t b where a.rn = b.rn and b. name = 'sss' ;
Explained.
SQL > select * from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan hash value : 752965310
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 0 | SELECT STATEMENT | | 1 | 42 | 7 ( 0 )| 00: 01 : 22 |
| 1 | NESTED LOOPS | | | | | |
| 2 | NESTED LOOPS | | 1 | 42 | 7 (0) | 00: 01 : 22 | --可以看到cost确实降低了
| * 3 | TABLE ACCESS FULL | T | 1 | 21 | 6 ( 0 )| 00: 01 : 10 |
| * 4 | INDEX RANGE SCAN | T_IDX | 1 | | 0 ( 0 )| 00:00: 01 |
| 5 | TABLE ACCESS BY INDEX ROWID| T | 1 | 21 | 1 ( 0 )| 00:00: 12 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Predicate Information (identified by operation id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3 - filter( "B" . "NAME" = 'sss' )
4 - access ( "A" . "RN" = "B" . "RN" )
18 rows selected.
非in-list和嵌套循环操作,调整这个参数时,不会影响oracle优化器成本的运算,如下
SQL > set linesize 200 pagesize 999
SQL > explain plan for select * from t where rn < 200 ;
Explained.
SQL > select * from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan hash value : 470836197
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 0 | SELECT STATEMENT | | 199 | 4179 | 3 ( 0 )| 00:00: 35 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 199 | 4179 | 3 ( 0 )| 00:00: 35 |
| * 2 | INDEX RANGE SCAN | T_IDX | 199 | | 2 ( 0 )| 00:00: 24 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Predicate Information (identified by operation id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 - access ( "RN" < 200 )
14 rows selected.
SQL > alter session set optimizer_index_caching = 1 ;
Session altered.
SQL > explain plan for select * from t where rn < 200 ;
Explained.
SQL > select * from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plan hash value : 470836197
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 0 | SELECT STATEMENT | | 199 | 4179 | 3 ( 0 )| 00:00: 35 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 199 | 4179 | 3 ( 0 )| 00:00: 35 |
| * 2 | INDEX RANGE SCAN | T_IDX | 199 | | 2 (0) | 00:00: 24 | --可以看到cost确实没有改变
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Predicate Information (identified by operation id):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 - access ( "RN" < 200 )
14 rows selected.
OPTIMIZER_INDEX_COST_ADJ
这个初始化参数代表一个百分比,取值范围在1到10000之间.
该参数表示索引扫描和全表扫描成本的比较。缺省值100表示索引扫描成本等价转换与全表扫描成本。
这些参数对于CBO的执行具有重大影响,其缺省值对于数据库来说通常需要调整。
一般来说对于OPTIMIZER_INDEX_CACHING可以设置为90左右
对于大多数OLTP系统,OPTIMIZER_INDEX_COST_ADJ可以设置在10到50之间。对于数据仓库和DSS系统,
可能不能简单的把OPTIMIZER_INDEX_COST_ADJ设置为50,通常我们需要反复调整取得一个合理值.
更为具体的可以根据统计信息,db file scattered reads/db file sequential reads来计算.
本文通过实验对该参数的使用作出探讨和说明.
我们看到optimizer_index_cost_adj的缺省值为100.
[oracle@jumper udump]$ sqlplus eygle/eygle SQL*Plus: Release 9.2.0.3.0 - Production on Mon Jun 28 17:11:15 2004 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: SQL> show parameter optimizer_index_cost_adj NAME TYPE VALUE |
创建测试表:
SQL> create table t as select * from dba_objects; Table created. SQL> create index ind_owner on t(owner); Index created. SQL> analyze table t compute statistics; Table analyzed.
|
我们分别观察一下全表扫描和索引访问的成本:
SQL> set autotrace traceonly
|
Oracle在选择不同的访问路径时,会对全表扫描和索引扫描进行比较评估.
在比较的时候,Oracle会把索引扫描的成本转换为全表扫描的成本,和全表扫描的COST进行比较.这个转换需要一个转换因子.
就是optimizer_index_cost_adj:
optimizer_index_cost_adj * (Index Scan Cost) = 等价的 Full Scan Cost
这个 等价的 Full Scan Cost 就是来和全表扫描成本进行比较的.
而这个转换因子的临界值实际上就是Full Scan Cost 和 Index Scan Cost的比值.
即:
optimizer_index_cost_adj = Full Scan Cost / Index Scan Cost
SQL> set autotrace off (14/16)*100 1 row selected. |
我们通过调整optimizer_index_cost_adj来看一下执行计划的变化:
SQL> set autotrace traceonly SQL> alter session set optimizer_index_cost_adj = 87; Session altered. SQL> select * from t where owner='EYGLE'; Execution Plan 此时使用索引成本较低.等价全表扫描成本为: 87% * (Index Scan Cost) < Full Scan Cost 此时Oracle选择了索引. SQL> alter session set optimizer_index_cost_adj = 88; Session altered. SQL> select * from t where owner='EYGLE'; Execution Plan 此时使用索引成本较高.等价全表扫描成本为: 88% * (Index Scan Cost) > Full Scan Cost 所以Oracle选择了全表扫描. |
参考文档:
http://www.evdbt.com/SearchIntelligenceCBO.doc
About Me
.............................................................................................................................................
● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除
● 本文在itpub(http://blog.itpub.net/26736162/abstract/1/)、博客园(http://www.cnblogs.com/lhrbest)和个人微信公众号(xiaomaimiaolhr)上有同步更新
● 本文itpub地址:http://blog.itpub.net/26736162/abstract/1/
● 本文博客园地址:http://www.cnblogs.com/lhrbest
● 本文pdf版、个人简介及小麦苗云盘地址:http://blog.itpub.net/26736162/viewspace-1624453/
● 数据库笔试面试题库及解答:http://blog.itpub.net/26736162/viewspace-2134706/
● DBA宝典今日头条号地址:http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826
.............................................................................................................................................
● QQ群号:230161599(满)、618766405
● 微信群:可加我微信,我拉大家进群,非诚勿扰
● 联系我请加QQ好友(646634621),注明添加缘由
● 于 2017-11-01 09:00 ~ 2017-11-30 22:00 在魔都完成
● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
.............................................................................................................................................
● 小麦苗的微店:https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
● 小麦苗出版的数据库类丛书:http://blog.itpub.net/26736162/viewspace-2142121/
.............................................................................................................................................
使用微信客户端扫描下面的二维码来关注小麦苗的微信公众号(xiaomaimiaolhr)及QQ群(DBA宝典),学习最实用的数据库技术。
小麦苗的微信公众号 小麦苗的DBA宝典QQ群2 《DBA笔试面宝典》读者群 小麦苗的微店
.............................................................................................................................................