Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
optimizer_index_cost_adj
and
optimizer_index_caching
on Access Plans
Wolfgang Breitling
breitliw@centrexcc.com
Who am I
2 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Agenda
3 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Index Access Costs
4 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Single Table Access Path and o_i_c_a
OPTIMIZER_INDEX_COST_ADJ = 100
Access path: tsc Resc: 4698
Access path: index (no sta/stp keys) RSC_CPU: 0 RSC_IO: 27954
Access path: index (equal) RSC_CPU: 0 RSC_IO: 6891
BEST_CST: 4698.00 PATH: 2
OPTIMIZER_INDEX_COST_ADJ = 1
Access path: tsc Resc: 4698
Access path: index (no sta/stp keys) RSC_CPU: 0 RSC_IO: 27954
Access path: index (equal) RSC_CPU: 0 RSC_IO: 6891
BEST_CST: 68.91 PATH: 4
OPTIMIZER_INDEX_COST_ADJ = 1000
Access path: tsc Resc: 4698
Access path: index (no sta/stp keys) RSC_CPU: 0 RSC_IO: 27954
Access path: index (equal) RSC_CPU: 0 RSC_IO: 6891
BEST_CST: 4698.00 PATH: 2
5 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Single Table Access Path and o_i_c_a
optimizer_index_cost_adj/100
6 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Single Table Access Path and o_i_c_a
OPTIMIZER_INDEX_COST_ADJ = 69
Access path: tsc Resc: 4698
Access path: index (no sta/stp keys) RSC_CPU: 0 RSC_IO: 27954
Access path: index (equal) RSC_CPU: 0 RSC_IO: 6891 [4754.79]
BEST_CST: 4698.00 PATH: 2
OPTIMIZER_INDEX_COST_ADJ = 68
Access path: tsc Resc: 4698
Access path: index (no sta/stp keys) RSC_CPU: 0 RSC_IO: 27954
Access path: index (equal) RSC_CPU: 0 RSC_IO: 6891
BEST_CST: 4685.88 PATH: 4
7 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Joins and o_i_c_a
8 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
o_i_c_a and NL Joins
OPTIMIZER_INDEX_COST_ADJ = 100
Outer table: cost: 4698 cdn: 144 rcz: 43
Inner table:
Access path: tsc Resc: 2541 Join: 370602
Access path: index (unique) RSC_IO: 2 Join: 4986
Access path: index (scan) RSC_IO: 3 Join: 5130
Access path: index (no sta/stp keys) RSC_IO: 3153 Join: 458730
Access path: index (scan) RSC_IO: 271 Join: 43722
Access path: index (eq-unique) RSC_IO: 2 Join: 4986
Best NL cost: 4986
No fractional costs shown despite event 10183
OPTIMIZER_INDEX_COST_ADJ = 10
Outer table: cost: 689 cdn: 144 rcz: 43 689 + 144*2 * 10/100
Inner table:
Access path: tsc Resc: 2541 Join: 366593
Access path: index (unique) RSC_IO: 2 Join: 718 14.4%
Access path: index (scan) RSC_IO: 3 Join: 732 14.3%
Access path: index (no sta/stp keys) RSC_IO: 3153 Join: 46092 10.0%
Access path: index (scan) RSC_IO: 271 Join: 4592 10.5%
Access path: index (eq-unique) RSC_IO: 2 Join: 718 14.4%
Best NL cost: 718
9 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
o_i_c_a and HA and SM Joins
10 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Optimizer_Index_Caching
11 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Optimizer_Index_Caching
rsc_io
4,500
4,000
3,500
3,000
2,500
2,000
1,500
1,000
500
0
0 10 20 30 40 50 60 70 80 90 100 o_i_c
12 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Optimizer_Index_Caching
13 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Optimizer_Index_Caching
4226 4225
4218
33
4200
4185
32
4150 4153
32
4121
4100 33
4088
32
4056
4050
32
4024
4000
3991
3959
3950
0 1 2 3 4 5 6 7 8 9 10
14 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Index Access Costs
15 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Optimizer_Index_Caching
Unlike optimizer_index_cost_adj,
optimizer_index_caching
affects only the cost of NL joins
16 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
o_i_c_a and o_i_c together
17 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
o_i_c_a and o_i_c together
2,000,000
o_i_c_a = 100 o_i_c_a = 10 o_i_c_a = 1
1,820,341 = 7387 + 1,812,954
1,800,000
1,600,000
1,400,000
1,200,000
1,000,000
800,000
600,000
400,000
18 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
o_i_c_a and o_i_c together
19 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Optimizer_Index_Caching
db_cache_size=64M ( 8192 8K blocks )
30,000.0
3,508 7,015 14,029 28,057
#LB
25,000.0
20,000.0
15,000.0
10,000.0
5,000.0
0.0
0 10 20 30 40 50 60 70 80 90 o_i _c 100
20 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Source: http://www.tpc.org/information/sessions/sigmod/sld029.htm
21 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
select sum(o.totalprice)
from order_1 o
, customer_1 c
, lineitem_1 l
, part_1 p
where o.cust_id = c.cust_id
and l.order_id = o.order_id
and l.part_id = p.part_id
and o.orderpriority = '2-HIGH'
and c.mktsegment = 'HOUSEHOLD'
and p.mfgr = 'Manufacturer#2'
and p.brand = 'Brand#33'
and l.shipdate > to_date('2005-01-22','yyyy-mm-dd')
22 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Access Path Evolution
optimizer_index_cost_adj = 100 optimizer_index_caching = 0
row sort1640
1
source
cardinality cost (access path)
NL = 1586 + 160*1 = 1746
SM = 1586 + 53 + 2 + 11 = 1652
HA HA = 1586 + 53 + 1 = 1640
50 1640
NL = 37 + 160*1388 = 222117
HA O SM = 37 + 1388 + 2 + 2 = 1428
160 1426 1 1 (unique) HA = 37 + 1388 + 2 = 1426
P L
160 37 (iff) 238 1388 (tsc)
23 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Access Path Evolution
optimizer_index_cost_adj = 25 optimizer_index_caching = 90
row sort
source 1 1506
cardinality cost (access path)
NL = 1466 + 0.25* 160*1 = 1506
SM = 1466 + 53 + 2 + 11 = 1652
NL HA = 1466 + 53 + 1 = 1640
50 1506
NL = 37 + 0.25*160*368
0.25* = 14757
HA O SM = 37 + 1388 + 2 + 2 = 1428
160 1426 1 0 (unique) HA = 37 + 1388 + 2 = 1426
P L
160 37 (iff) 238 1388 (tsc)
24 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Access Path Evolution
optimizer_index_cost_adj = 10 optimizer_index_caching = 90
row sort
source 1 1443
cardinality cost (access path)
NL = 1436 + 0.1* 74*1 = 1443
SM = 1436 + 24 + 2 + 2 = 1462
NL HA = 1436 + 24 + 2 = 1460
50 1443
NL = 1388 + 0.1*238*1
0.1* = 1411.8
NL C SM = 1388 + 340 + 2 + 174 = 1904
238 1412 1 0 (unique) HA = 1388 + 340 + 1 = 1729
L O
238 1388 (tsc) 1 0 (unique)
25 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Access Path Evolution
mbrc=8, mreadtim=1.21 * sreadtim optimizer_index_caching = 0
NL = 37 + 160*1382 = 221157
HA O SM* = 369 + 1382 + 1 = 1752
160 1420 1 1 (unique) HA = 37 + 1382 + 1 = 1420
P L
160 37 (iff) 238 1382 (tsc)
26 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Access Path Evolution
mbrc=8, mreadtim=4.84 * sreadtim optimizer_index_caching = 0
row sort
source
1 5986
cardinality cost (access path)
NL = 5825 + 160*1 = 5985
SM = 5825 + 207 + 2 = 6034
NL HA = 5825 + 207 + 1 = 6033
50 5986
♣
NL = 140 + 160*4230 = 676939
HA O SM = 139 + 5525 + 1 = 5666
160 5666 1 1 (unique) HA = 139 + 5525 = 5665
♣ but best NL cost reported as 884140 = 140 + 160*5525
P L
160 140 (iff) 238 5525 (tsc)
27 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Access Path Evolution
mbrc=8, mreadtim=4.84 * sreadtim optimizer_index_caching = 90
sort
1 5986
NL = 5825 + 160*1 = 5985
SM = 5825 + 207 + 2 = 6034
NL HA = 5825 + 207 + 1 = 6033
50 5986
♣
NL = 140 + 160*439 = 70379
HA O SM = 139 + 5525 + 1 = 5666
160 5666 1 1 (unique) HA = 139 + 5525 = 5665
♣ but best NL cost reported as 884140 = 140 + 160*5525
P L
160 140 (iff) 238 5525 (tsc)
28 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Access Path Evolution
mbrc=8, mreadtim=12.1 * sreadtim optimizer_index_caching = 90
sort
1 14361
NL = 14201 + 160*1 = 14361
SM = 14200 + 516 [+2] = 14718
NL HA = 14200 + 516 [+1] = 14717
50 14361
♣
NL = 229 + 160*439 = 70468
HA O SM = 228 + 1388 + 2 + 2 = 1428
160 14041 1 1 (unique) HA = 228 + 1388 + 2 = 1426
♣ but best NL cost reported as 2209989
= 229 + 160*13811
P L
160 229 (iff) 238 13811 (tsc)
29 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
My favorite websites
30 © Wolfgang Breitling, Centrex Consulting Corporation Hotsos Symposium, March 6-9, 2005
Wolfgang Breitling
breitliw@centrexcc.com