你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle 10g 10053事件

[日期:2012-02-13] 来源:Linux社区  作者:rulev5 [字体:大 中 小]
尽管两种关联顺序里面的Hash Join的代价都是一样的5.51,但是第一个表关联的顺序的resc_cpu的代价要小,索引CBO最终选择了第一个表关联顺序的下的HASH JOIN
方式作为最终的执行计划,即T关联T1通过Hash Join的方式来做关联的代价最小。
    下面这个部分是通过CBO给出的一个执行计划报告,其中ROWS例对应于上面每个操作的 cardinality rounded cost 对应于每一个操作的cost值。
============
Plan Table
============
------------------------------------------------+-----------------------------------+
| Id  | Operation                     | Name    | Rows  | Bytes | Cost  | Time      |
------------------------------------------------+-----------------------------------+
| 0   | SELECT STATEMENT              |         |       |       |     6 |           |
| 1   |  HASH JOIN                    |         |    81 |   810 |     6 |  00:00:01 |
| 2   |   INDEX RANGE SCAN            | IND_T   |    82 |   328 |     2 |  00:00:01 |
| 3   |   TABLE ACCESS BY INDEX ROWID | T1      |    99 |   594 |     3 |  00:00:01 |
| 4   |    INDEX RANGE SCAN           | IND_T1  |    99 |       |     2 |  00:00:01 |
------------------------------------------------+-----------------------------------+
Predicate Information:
----------------------
1 - access("T"."X"="T1"."X")
2 - access("T"."X"<100)
4 - access("T1"."X"<100)

Content of other_xml column
===========================
  db_version     : 10.2.0.4
  parse_schema   : SYS
  plan_hash      : 2145127414
  Outline Data:
  通过一系列的计算和比较,CBO最终选择了上面的执行计划作为SQL的最终执行计划。trace文件最后,这里不做讨论。


下面是帮一个网友看的一个问题


这个是测试环境,走索引的


SINGLE TABLE ACCESS PATH
  Single Table Cardinality Estimation for CLAIMS[CLAIMS]

  Table: CLAIMS  Alias: CLAIMS
    Card: Original: 100817.000000  Rounded: 6470  Computed: 6469.52  Non Adjusted: 6469.52
  Access Path: TableScan
    Cost:  2845.00  Resp: 2845.00  Degree: 0
      Cost_io: 2805.00  Cost_cpu: 662177710
      Resp_io: 2805.00  Resp_cpu: 662177710
  Access Path: index (RangeScan)
    Index: CLAIMS_IDX16
    resc_io: 6904.60  resc_cpu: 275804847
    ix_sel: 0.333333  ix_sel_with_filters: 0.333333
    Cost: 6921.26  Resp: 6921.26  Degree: 1
  Access Path: index (RangeScan)
    Index: CLAIMS_IDX30
    resc_io: 3346.60  resc_cpu: 171975781
    ix_sel: 0.500000  ix_sel_with_filters: 0.500000
    Cost: 3356.98  Resp: 3356.98  Degree: 1
  ****** trying bitmap/domain indexes ******
  Access Path: index (AllEqRange)
    Index: CLAIMS_IDX16
    resc_io: 46.00  resc_cpu: 3689036
    ix_sel: 0.166667  ix_sel_with_filters: 0.166667
    Cost: 46.22  Resp: 46.22  Degree: 0
  Access Path: index (AllEqRange)
    Index: CLAIMS_IDX16
    resc_io: 46.00  resc_cpu: 3689036
    ix_sel: 0.166667  ix_sel_with_filters: 0.166667
    Cost: 46.22  Resp: 46.22  Degree: 0
  Access Path: index (AllEqRange)
    Index: CLAIMS_IDX30
    resc_io: 33.00  resc_cpu: 2589658
    ix_sel: 0.250000  ix_sel_with_filters: 0.250000
    Cost: 33.16  Resp: 33.16  Degree: 0
  Access Path: index (AllEqRange)
    Index: CLAIMS_IDX30
    resc_io: 33.00  resc_cpu: 2589658
    ix_sel: 0.250000  ix_sel_with_filters: 0.250000
    Cost: 33.16  Resp: 33.16  Degree: 0
  Access path: Bitmap index - accepted
    Cost: 2730.185047 Cost_io: 2721.380943 Cost_cpu: 145743285.440609 Sel: 0.166667
    Not Believed to be index-only
  ****** finished trying bitmap/domain indexes ******
******** Begin index join costing ********
******** End index join costing ********
  Best:: AccessPath: IndexBitmap
         Cost: 2730.19  Degree: 1  Resp: 2730.19  Card: 6469.52  Bytes: 0
        

这个是真实环境,不走索引


SINGLE TABLE ACCESS PATH
  Single Table Cardinality Estimation for CLAIMS[CLAIMS]

  Table: CLAIMS  Alias: CLAIMS
    Card: Original: 101522.000000  Rounded: 6570  Computed: 6570.11  Non Adjusted: 6570.11
  Access Path: TableScan
    Cost:  5949.01  Resp: 5949.01  Degree: 0
      Cost_io: 5900.00  Cost_cpu: 811350733
      Resp_io: 5900.00  Resp_cpu: 811350733
  Access Path: index (RangeScan)
    Index: CLAIMS_IDX16
    resc_io: 39801.47  resc_cpu: 514492135
    ix_sel: 0.333333  ix_sel_with_filters: 0.333333
    Cost: 39832.55  Resp: 39832.55  Degree: 1
  Access Path: index (RangeScan)
    Index: CLAIMS_IDX30
    resc_io: 25940.30  resc_cpu: 344175912
    ix_sel: 0.500000  ix_sel_with_filters: 0.500000
    Cost: 25961.09  Resp: 25961.09  Degree: 1
  Best:: AccessPath: TableScan
         Cost: 5949.01  Degree: 1  Resp: 5949.01  Card: 6570.11  Bytes: 0linux
相关资讯       Oracle基础教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款