jimeper的脚印
如果永远不给自己机会,永远不知道未来的世界会更大,同一个天空,同一个梦想
                                                                                                                        ----------挑战你自己
如果我们放眼从累生历劫去看,那么一切的众生,谁不曾做过我的父母、兄弟姊妹、亲戚眷属?谁不曾做过我的仇敌冤家?如果说有恩,个个与我有恩;如果说有冤,个个与我有冤。这样子我们还有什么恩怨亲疏之别呢?再就智慧愚笨来说,人人有聪明的时候,也有愚痴的时候,聪明的人可能变愚痴,愚痴的人也可能变聪明。最坏的人,也曾做过许多好事,而且不会永远坏;好人也曾做过许多坏事,将来也不一定会好。如此我们反覆思索,所谓的冤亲、贤愚,这许多差别的概念,自然就会渐渐淡了。这绝对不是混沌,也不是不知好坏,而是要将我们无始以来的偏私差别之见,以一视同仁的平等观念罢了!
posts - 212,comments - 30,trackbacks - 0

关于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

posted on 2009-02-26 16:57 jimeper 阅读(477) 评论(0) 编辑 收藏