Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Help understanding CBO plan
Hi,
I see that CBO did a wrong choice for his plan (HA join is the best, not
NL).
I did a 10053 trace and there 2 two things I don't understand :
How is comptutated this line :
BEST_CST: 2166.00 PATH: 4 Degree: 1
?
and how can the cost and TBSEL be negative
CST: -4659 IXSEL: 1.5767e-01 TBSEL: -5.5476e-02
?
This gives for the this NL join this cost : Join resc: 2167 , the best
for CBO.
How is computed this value 2167 from the CST -4659 ?
I use this for stats :
dbms_stats.gather_schema_stats('SYSADM',CASCADE=>TRUE,ESTIMATE_PERCENT
=>NULL,method_opt=>'FOR ALL COLUMNS SIZE 75
');
Thanks for your help.
Oracle8i Enterprise Edition Release 8.1.7.2.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.2.0 - 64bit Production
...
SELECT 35150, 'AP',
A.BUSINESS_UNIT, A.FISCAL_YEAR, A.ACCOUNTING_PERIOD, 0, 0, A.LEDGER_GROUP,
A.LEDGER, A.ACCOUNT, A.ALTACCT, B.VENDOR_SETID, B.VENDOR_ID, ' ', ' ', ' ',
'REFCO', A.DOC_TYPE, A.DOC_SEQ_NBR, A.DOC_SEQ_DATE, A.ACCOUNTING_DT,
A.BUSINESS_UNIT_GL, A.BUSINESS_UNIT, A.JOURNAL_ID, ' ', ' ', B.INVOICE_ID, B.INVOICE_DT, A.APPL_JRNL_ID, ' ', 0, 0, 0, 0, 0, 0, A.PYMNT_CNT, A.UNPOST_SEQ, A.VOUCHER_ID, A.CURRENCY_CD, A.FOREIGN_CURRENCY, A.RT_TYPE, A.RATE_DIV, A.RATE_MULT, A.MOVEMENT_FLAG, A.MONETARY_AMOUNT, A.FOREIGN_AMOUNT, 0, 0, 0, 0
OPTIMIZER_FEATURES_ENABLE = 8.1.7 OPTIMIZER_MODE/GOAL = Choose OPTIMIZER_PERCENT_PARALLEL = 0 HASH_AREA_SIZE = 3145728 HASH_JOIN_ENABLED = TRUE
OPTIMIZER_MAX_PERMUTATIONS = 80000 OPTIMIZER_INDEX_CACHING = 70 OPTIMIZER_INDEX_COST_ADJ = 50
_INDEX_JOIN_ENABLED = FALSE _SORT_ELIMINATION_COST_RATIO = 0 _OR_EXPAND_NVL_PREDICATE = TRUE _NEW_INITIAL_JOIN_ORDERS = FALSE _OPTIMIZER_MODE_FORCE = TRUE _OPTIMIZER_UNDO_CHANGES = FALSE _UNNEST_SUBQUERY = FALSE _PUSH_JOIN_UNION_VIEW = FALSE _FAST_FULL_SCAN_ENABLED = TRUE _OPTIM_ENHANCE_NNULL_DETECTION = TRUE _ORDERED_NESTED_LOOP = FALSE _NESTED_LOOP_FUDGE = 100 _NO_OR_EXPANSION = FALSE _QUERY_COST_REWRITE = TRUE
_IMPROVED_ROW_LENGTH_ENABLED = TRUE _USE_NOSEGMENT_INDEXES = FALSE _ENABLE_TYPE_DEP_SELECTIVITY = TRUE _IMPROVED_OUTERJOIN_CARD = TRUE _OPTIMIZER_ADJUST_FOR_NULLS = TRUE _OPTIMIZER_CHOOSE_PERMUTATION = 0 _USE_COLUMN_STATS_FOR_FUNCTION = TRUE _SUBQUERY_PRUNING_ENABLED = TRUE _SUBQUERY_PRUNING_REDUCTION_FACTOR = 50 _SUBQUERY_PRUNING_COST_FACTOR = 20 _LIKE_WITH_BIND_AS_EQUALITY = FALSE _TABLE_SCAN_COST_PLUS_ONE = FALSE _SORTMERGE_INEQUALITY_JOIN_OFF = FALSE _DEFAULT_NON_EQUALITY_SEL_CHECK = TRUE _ONESIDE_COLSTAT_FOR_EQUIJOINS = TRUE
Column: BUSINESS_U Col#: 1 Table: PS_VCHR_ACCTG_LINE Alias: A NDV: 27 NULLS: 0 DENS: 9.2429e-07 Column: FISCAL_YEA Col#: 39 Table: PS_VCHR_ACCTG_LINE Alias: A NDV: 2 NULLS: 0 DENS: 9.2429e-07 Column: ACCOUNTING Col#: 38 Table: PS_VCHR_ACCTG_LINE Alias: A NDV: 8 NULLS: 0 DENS: 9.2429e-07 Column: GL_DISTRIB Col#: 45 Table: PS_VCHR_ACCTG_LINE Alias: A NDV: 2 NULLS: 0 DENS: 9.2429e-07 TABLE: PS_VCHR_ACCTG_LINE ORIG CDN: 540958 CMPTD CDN: 20203Access path: tsc Resc: 2220 Resp: 2220 Access path: index (scan)
INDEX#: 278659 TABLE: PS_VCHR_ACCTG_LINE CST: 4332 IXSEL: 3.7345e-02 TBSEL: 3.7345e-02 Access path: index (scan) INDEX#: 54850 TABLE: PS_VCHR_ACCTG_LINE CST: 36297 IXSEL: 1.6207e-01 TBSEL: 1.6207e-01BEST_CST: 2166.00 PATH: 4 Degree: 1
Column: BUSINESS_U Col#: 1 Table: PS_VOUCHER Alias: B NDV: 27 NULLS: 0 DENS: 5.7362e-06 TABLE: PS_VOUCHER ORIG CDN: 87165 CMPTD CDN: 13743Access path: tsc Resc: 476 Resp: 476 Access path: index (scan)
INDEX#: 57473 TABLE: PS_VOUCHER CST: 13360 IXSEL: 1.5767e-01 TBSEL: 1.5767e-01 Access path: index (scan) INDEX#: 57470 TABLE: PS_VOUCHER CST: 1930 IXSEL: 1.5767e-01 TBSEL: 1.5767e-01BEST_CST: 476.00 PATH: 2 Degree: 1
INDEX#: 278659 TABLE: PS_VCHR_ACCTG_LINE CST: 1 IXSEL: 0.0000e+00 TBSEL: 2.9236e-07Join resc: 7348 resp:7348
INDEX#: 54850 TABLE: PS_VCHR_ACCTG_LINE CST: 2 IXSEL: 1.2687e-06 TBSEL: 2.0562e-07Join resc: 14219 resp:14219
Using index (ndv = 87165 sel = -2.3817e-05)
Best NL cost: 7348 resp: 7348
SM Join
Outer table:
resc: 476 cdn: 13743 rcz: 46 deg: 1 resp: 476
Inner table: PS_VCHR_ACCTG_LINE
resc: 2166 cdn: 20203 rcz: 121 deg: 1 resp: 2166
SORT resource Sort statistics Sort width: 5 Area size: 2125824 Degree: 1 Blocks to Sort: 103 Row size: 61 Rows: 13743 Initial runs: 1 Merge passes: 1 Cost / pass: 124 Total sort cost: 114 SORT resource Sort statistics Sort width: 5 Area size: 2125824 Degree: 1 Blocks to Sort: 357 Row size: 144 Rows: 20203 Initial runs: 2 Merge passes: 1 Cost / pass: 429 Total sort cost: 393
INDEX#: 57470 TABLE: PS_VOUCHER CST: 1930 IXSEL: 1.5767e-01 TBSEL: 1.5767e-01Outer table:
SORT resource Sort statistics Sort width: 5 Area size: 2125824 Degree: 1 Blocks to Sort: 357 Row size: 144 Rows: 20203 Initial runs: 2 Merge passes: 1 Cost / pass: 429 Total sort cost: 393
hash_area: 384 buildfrag: 385 probefrag: 329
ppasses: 2
Hash join Resc: 2676 Resp: 2676
Join result: cost: 2676 cdn: 3185 rcz: 167 Best so far: TABLE#: 0 CST: 476 CDN: 13743 BYTES: 632178 Best so far: TABLE#: 1 CST: 2676 CDN: 3185 BYTES: 531895 ***********************
INDEX#: 57470 TABLE: PS_VOUCHER CST: 1 IXSEL: 7.2764e-05 TBSEL: 7.2764e-05Join resc: 12268 resp:12268
INDEX#: 57473 TABLE: PS_VOUCHER CST: -4659 IXSEL: 1.5767e-01 TBSEL: -5.5476e-02Join resc: 2167 resp:2167
INDEX#: 57470 TABLE: PS_VOUCHER CST: 1 IXSEL: 0.0000e+00 TBSEL: 0.0000e+00Join resc: 12268 resp:12268
Using index (ndv = 87165 sel = -2.3817e-05)
Best NL cost: 2167 resp: 2167
SM Join
Outer table:
resc: 2166 cdn: 20203 rcz: 121 deg: 1 resp: 2166
Inner table: PS_VOUCHER
resc: 476 cdn: 13743 rcz: 46 deg: 1 resp: 476
SORT resource Sort statistics Sort width: 5 Area size: 2125824 Degree: 1 Blocks to Sort: 103 Row size: 61 Rows: 13743 Initial runs: 1 Merge passes: 1 Cost / pass: 124 Total sort cost: 114
hash_area: 384 buildfrag: 385 probefrag: 329
ppasses: 2
Hash join Resc: 2669 Resp: 2669
Join result: cost: 2167 cdn: 3185 rcz: 167 Best so far: TABLE#: 1 CST: 2166 CDN: 20203 BYTES: 2444563 Best so far: TABLE#: 0 CST: 2167 CDN: 3185 BYTES: 531895Final:
-- http://www.freelists.org/webpage/oracle-lReceived on Tue Oct 26 2004 - 03:21:26 CDT
![]() |
![]() |