CBO Cost Formulas成本計算公式大全: 成本模型:連線方式Join method 注意 連線基數(Join Cardinality)不受到連線方式(join method) 的影響, oracle中主要的三種join method HASH JOIN、Nested Loops、Sort Merge:
  • Nested Loops巢狀迴圈成本公式:
    • Cost(outer)+Cost(inner))*cardinality(outer)
  • Sort merge 合併排序連線成本公式:
    • Cost(outer) + Cost(inner) + Sort(outer) + Sort(inner)
  • Hash Join 雜湊連線公式:
    • Cost(outer) + Cost(inner) + Build(outer) + Probe(inner)
  Index Unique Scan Cost成本計算 INDEX UNIQUE SCAN COST = (BLEVEL (1-(OIC/100)) + 1) * (OICA/100)   Index Range Scan Cost成本計算 INDEX RANGE SCAN COST = (BLEVEL + FF*LFBL)*(1-(OIC/100))+ FF*CLUF)* (OICA/100)     formula does not include the CPU cost
  • BLEVEL = number of branch levels in index
  • add +1 for leaf block
  • FF = filtering factor – selectivity
  • LFBL = number of leaf blocks
  • CLUF = index clustering factor
  • OIC = optimizer_index_caching(default 0)
  • OICA = optimizer_index_cost_adj parameter(default=100)
  CPU costing啟用的情況下: mreadtime -Average time , in milliseconds, for a multi-block read (according to sys.aux_stats$) sreadtime - Average time , in milliseconds, for a single-block read (according to sys.aux_stats$) MBRC - Average number of blocks to be read in a multi-block read (according to sys.aux_stats$ #SRDs - number of single block reads #MRDs - number of multi block reads #CPUCycles - number of CPU Cycles sreadtime = ioseektim + db_block_size/iotfrspeed mreadtim = ioseektim + db_file_multiblock_read_count * db_block_size / iotrfspeed #MRds = #Blks/MBRC Cost 成本本身 =(#SRds * sreadtim +#MRds * mreadtim +