-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_part_r7.sql
144 lines (102 loc) · 2.86 KB
/
demo_part_r7.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
-- demo non-use of bitmap indexes on large partitioned table
-- favour index, avoid surprises!
alter session set optimizer_mode = first_rows_1;
set autotrace off
cle scre
set echo on
set feedb on
cle scre
-- demo use/non-use of bitmap indexes on large partitioned table
alter table t_ccc add ( att1 varchar2(32), m1 number ) ;
alter table pt_ccc add ( att1 varchar2(32), m1 number ) ;
update pt_ccc set att1 = 'V' || to_char ( mod ( pt_id, 999) )
, m1 = mod ( pt_id, 200 )
;
update t_ccc set att1 = 'V' || to_char ( mod ( t_id, 999) )
, m1 = mod ( t_id, 200 )
;
set echo off
prompt .
prompt we added two columns with simple data
prompt .
host read -p "put bitmap indexes on it..."
drop index pt_ccc_ba1;
drop index pt_ccc_bm1;
drop index t_ccc_ba1;
drop index t_ccc_bm1;
cle scre
set echo on
create bitmap index pt_ccc_ba1 on pt_ccc ( att1 ) local ;
create bitmap index pt_ccc_bm1 on pt_ccc ( m1 ) local ;
create bitmap index t_ccc_ba1 on t_ccc ( att1 ) ;
create bitmap index t_ccc_bm1 on t_ccc ( m1 ) ;
set echo off
prompt .
prompt two columns with bitmap indexes on them. note: LOCAL
prompt let see how that works
prompt .
host read -p "first.. bitmap indexes on T, as intended "
set linesize 130
/*+ use index t */
set echo on
set autotrace on explain
select /*+ index_combine(t t_ccc_bm1 t_ccc_ba1) */
count (*), max (created_dt) as lastdd from t_ccc t
where att1 = 'V1'
and m1 = 1
and t_id < 35000
;
set echo off
prompt .
prompt select from normal table, expect bitmap-and combination
prompt and notice the PK is not used, filter is on the table-row.
prompt .
host read -p "use of bitmap indexes on T, as intended "
set autotrace on stat
set echo on
l
/
set echo off
prompt .
prompt how much io was needed ?
prompt .
host read -p "bitmap index on T, read few blocks..."
set autotrace on explain
set echo on
select
count (*), max (created_dt) as lastdd from pt_ccc t
where att1 = 'V1'
and m1 = 1
and pt_id < 35000 -- try for several partitions
;
set echo off
prompt .
prompt the PT also has bitmap indexes..
prompt in this case, only 1 bitmap per partitions (needs fix..)
prompt but also note that it needs to scan MULITPLE-local bitmap-indexes
prompt .
host read -p "how is use of bitmap indexes on PT, multi-partition ?"
set autotrace on stat
cle scr
set echo on
l
/
set echo off
cle scre
set echo on
/
set echo off
prompt .
prompt And how much io was done on the PT
prompt just to count 8 records ?
prompt .
host read -p "bitmap index on partitions of PT, how many blocks..."
prompt .
prompt Bitmap-indexes are local,
prompt but typical use may cover many/all partitions.
prompt .
prompt 1. CBO seems to use less of the bitmap-indexes (is solvable..)
prompt 2. but.. looping over partitions can (will) hurt performance.
prompt .
prompt note: I'd like something of a partial-global (bitmap-)index here...?
prompt .