关于Optimizer_index_cost_adj参数的设置

简介: 关于Optimizer_index_cost_adj参数的设置 Thomas建议:对于许多系统,应到考虑设置这两个参数为非默认值,至少测试一下两种极端情形: 1. optimizer_index_caching=0 和 optimizer_index_cost_adj=100的默认值. 他们一般适用于许多数据仓库/报表系统 2. otpimizer_index_caching=90和optimizer_index_cost_adj=25的设置,他们一般适用于许多事物处理系统/oltp系统. 对于数据仓库和DSS系统要反复调整来取一个合理值。

关于Optimizer_index_cost_adj参数的设置

Thomas建议:
对于许多系统,应到考虑设置这两个参数为非默认值,至少测试一下两种极端情形:

1. optimizer_index_caching=0 和 optimizer_index_cost_adj=100的默认值. 他们一般适用于许多数据仓库/报表系统

2. otpimizer_index_caching=90和optimizer_index_cost_adj=25的设置,他们一般适用于许多事物处理系统/oltp系统.

对于数据仓库和DSS系统要反复调整来取一个合理值。
Oracle在选择不同的访问路径时,会对全表扫描和索引扫描进行比较评估,在比较的时候,
Oracle会把索引扫描的成本转换为全表扫描的成本,和全表扫描的COST进行比较。这个转换需要一个转换因子,就是Optimizer_index_cost_adj;
Optimizer_index_cost_adj*(index scan cost)=等价的Full Scan cost

所以 optimizer_index_cost_adj = Full Scan Cost / Index Scan Cost

在缺省情况下:Optimizer_index_cost_adj=100

SQL> show parameter optimizer_index_cost_adj
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
optimizer_index_cost_adj             integer     100
SQL> create table t3 as select * from dba_objects;
Table created

SQL>
SQL> create index ind_owner on t3(owner);
Index created
SQL> analyze table t3 compute statistics;

SQL> set autotrace on
SQL> set timing on
SQL> set autotrace traceonly

SQL> alter session set optimizer_index_cost_adj=43;

Session altered.

select  /*+ FULL(t3)*/* from bia_stg.t3 t3 where owner='BIA_STG';

322 rows selected.

Execution Plan
----------------------------------------------------------
Plan hash value: 2574254479

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |  3044 |   255K|   130   (2)| 00:00:02 |
|*  1 |  TABLE ACCESS FULL| T3   |  3044 |   255K|   130   (2)| 00:00:02 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("OWNER"='BIA_STG')

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
        739  consistent gets
          0  physical reads
          0  redo size
      23185  bytes sent via SQL*Net to client
        700  bytes received via SQL*Net from client
         23  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
        322  rows processed

SQL> select /*+ index(t3 ind_owner)*/* from bia_stg.t3 t3 where owner='BIA_STG';

322 rows selected.

Execution Plan
----------------------------------------------------------
Plan hash value: 2790462862

--------------------------------------------------------------------------------
---------

| Id  | Operation                   | Name      | Rows  | Bytes | Cost (%CPU)| T
ime     |

--------------------------------------------------------------------------------
---------

|   0 | SELECT STATEMENT            |           |  3044 |   255K|    89   (0)| 0
0:00:02 |

|   1 |  TABLE ACCESS BY INDEX ROWID| T3        |  3044 |   255K|    89   (0)| 0
0:00:02 |

|*  2 |   INDEX RANGE SCAN          | IND_OWNER |  3044 |       |     8   (0)| 0
0:00:01 |

--------------------------------------------------------------------------------
---------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OWNER"='BIA_STG')

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
         65  consistent gets
          0  physical reads
          0  redo size
      23185  bytes sent via SQL*Net to client
        700  bytes received via SQL*Net from client
         23  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
        322  rows processed

optimizer_index_cost_adj = Full Scan Cost / Index Scan Cost* 100=130/89 * 100=1.460 * 100

=146

optimizer_index_cost_adj调整为147

目录
相关文章
|
8月前
|
机器学习/深度学习 人工智能
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
rank()、dense-rank()、row-number()的区别
rank()、dense-rank()、row-number()的区别
119 0
|
关系型数据库 MySQL
MySQL - 排序函数 Rank() Over()、Dense_rank() Over()、Row_number() Over()
MySQL - 排序函数 Rank() Over()、Dense_rank() Over()、Row_number() Over()
439 0
MySQL - 排序函数 Rank() Over()、Dense_rank() Over()、Row_number() Over()
|
关系型数据库 MySQL
MYSQL实现排名函数RANK,DENSE_RANK和ROW_NUMBER
本文介绍了MYSQL实现排名函数RANK,DENSE_RANK和ROW_NUMBER
244 0
|
Prometheus Cloud Native
详解Prometheus range query中的step参数
详细介绍了Prometheus查询参数step的作用
8034 0
|
Oracle 关系型数据库 索引
20180316不使用INDEX FULL SCAN (MIN/MAX)
[20180316]为什么不使用INDEX FULL SCAN (MIN/MAX).txt --//链接:http://www.itpub.net/thread-2100456-1-1.
1193 0