ROWID走索引之判决:
作了个10053,以下是trace 文件部分内容 走索引
***********************
Table Stats::
Table: T Alias: T
#Rows: 0 #Blks: 1 AvgRowLen: 0.00
Index Stats::
Index: I_T Col#: 1
LVLS: 0 #LB: 0 #DK: 0 LB/K: 0.00 DB/K: 0.00 CLUF: 0.00
***************************************
1-ROW TABLES: T[T]#0
***************************************
SINGLE TABLE ACCESS PATH
Column (#1001): ROWID(ROWID) NO STATISTICS (using defaults)
AvgLen: 10.00 NDV: 0 Nulls: 0 Density: 0.0000e+000
Table: T Alias: T
Card: Original: 0 Rounded: 1 Computed: 0.00 Non Adjusted: 0.00
Access Path: TableScan
Cost: 2.00 Resp: 2.00 Degree: 0
Cost_io: 2.00 Cost_cpu: 7121
Resp_io: 2.00 Resp_cpu: 7121
Access Path: Rowid
Cost: 1.00 Resp: 1.00 Degree: 0
Cost_io: 1.00 Cost_cpu: 7271
Resp_io: 1.00 Resp_cpu: 7271
kkofmx: index filter:"T".ROWID='AAAQ9uAACAAABacAAB'
Access Path: index (FullScan)
Index: I_T
resc_io: 0.00 resc_cpu: 200
ix_sel: 1 ix_sel_with_filters: 1
Cost: 0.00 Resp: 0.00 Degree: 1
Best:: AccessPath: IndexRange Index: I_T
Cost: 0.00 Degree: 1 Resp: 0.00 Card: 1.00 Bytes: 0
走表
INGLE TABLE ACCESS PATH
Column (#1001): ROWID(ROWID) NO STATISTICS (using defaults)
AvgLen: 10.00 NDV: 3 Nulls: 0 Density: 0.33333
Table: A Alias: A
Card: Original: 3 Rounded: 1 Computed: 0.03 Non Adjusted: 0.03
Access Path: TableScan
Cost: 3.00 Resp: 3.00 Degree: 0
Cost_io: 3.00 Cost_cpu: 36167
Resp_io: 3.00 Resp_cpu: 36167
Access Path: Rowid
Cost: 1.00 Resp: 1.00 Degree: 0
Cost_io: 1.00 Cost_cpu: 7271
Resp_io: 1.00 Resp_cpu: 7271
kkofmx: index filter:"A".ROWID='AAAQ/LAACAAABacAAD'
Access Path: index (FullScan)
Index: IDX_A_ID
resc_io: 1.00 resc_cpu: 7721
ix_sel: 1 ix_sel_with_filters: 1
Cost: 1.00 Resp: 1.00 Degree: 1
One row Card: 1.00
Best:: AccessPath: RowId
Cost: 1.00 Degree: 1 Resp: 1.00 Card: 1.00 Bytes: 0
在 NULL 约束下并且PK的约束的话~是必须要table access full的 因为首先要保证的是结果的准确
在NOT NULL 且数据位0的情况下 index的 block 为0,table的至少为1 那么index的cost就是0,CBO当然会选择cost低的来执行了
NOT NULL约束保证了结果准确性 才选择成本低的INDEX
说明一点要做好表信息分析收集工作