Skip to content

Commit 0e6e4a0

Browse files
author
Jorgen Loland
committed
BUG#11754168 followup: trying to stabilize index_merge_innodb.test
1 parent 5100dbc commit 0e6e4a0

File tree

3 files changed

+80
-94
lines changed

3 files changed

+80
-94
lines changed

mysql-test/include/index_merge1.inc

+30-27
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ if ($index_merge_random_rows_in_EXPLAIN)
6868
{
6969
--replace_column 9 #
7070
}
71-
explain select * from t0 where key1 < 3 or key2 <4;
71+
explain select * from t0 where key1 < 3 or key2 <3;
7272

7373
if ($index_merge_random_rows_in_EXPLAIN)
7474
{
@@ -96,7 +96,7 @@ if ($index_merge_random_rows_in_EXPLAIN)
9696
{
9797
--replace_column 9 #
9898
}
99-
explain select * from t0 use index (i1,i2) where (key1 < 3 or key2 <4) and key3 = 50;
99+
explain select * from t0 use index (i1,i2) where (key1 < 3 or key2 <3) and key3 = 50;
100100

101101
if ($index_merge_random_rows_in_EXPLAIN)
102102
{
@@ -118,7 +118,7 @@ if ($index_merge_random_rows_in_EXPLAIN)
118118
}
119119
explain
120120
select * from t0 where key1<3 or key2<3 or (key1>5 and key1<8) or
121-
(key1>10 and key1<12) or (key2>100 and key2<110);
121+
(key1>10 and key1<12) or (key2>100 and key2<105);
122122

123123
# 5. Check index_merge with conjuncts that are always true/false
124124
# verify fallback to "range" if there is only one non-confluent condition
@@ -160,7 +160,7 @@ if ($index_merge_random_rows_in_EXPLAIN)
160160
{
161161
--replace_column 9 #
162162
}
163-
explain select key1 from t0 where (key1 <=> null) or (key2 < 5) or
163+
explain select key1 from t0 where (key1 <=> null) or (key2 < 3) or
164164
(key3=10) or (key4 <=> null);
165165

166166
if ($index_merge_random_rows_in_EXPLAIN)
@@ -176,32 +176,32 @@ if ($index_merge_random_rows_in_EXPLAIN)
176176
--replace_column 9 #
177177
}
178178
explain select * from t0 where
179-
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 5 or key6 < 5);
179+
(key1 < 3 or key2 < 3) and (key3 < 3 or key4 < 3) and (key5 < 5 or key6 < 5);
180180

181181
if ($index_merge_random_rows_in_EXPLAIN)
182182
{
183183
--replace_column 9 #
184184
}
185185
explain
186-
select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
186+
select * from t0 where (key1 < 3 or key2 < 5) and (key1 < 5 or key3 < 3);
187187

188-
select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
188+
select * from t0 where (key1 < 3 or key2 < 5) and (key1 < 5 or key3 < 3);
189189

190190

191191
if ($index_merge_random_rows_in_EXPLAIN)
192192
{
193193
--replace_column 9 #
194194
}
195195
explain select * from t0 where
196-
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 2 or key6 < 2);
196+
(key1 < 3 or key2 < 3) and (key3 < 3 or key4 < 3) and (key5 < 2 or key6 < 2);
197197

198198
# now index_merge is not used at all when "range" is possible
199199
if ($index_merge_random_rows_in_EXPLAIN)
200200
{
201201
--replace_column 9 #
202202
}
203203
explain select * from t0 where
204-
(key1 < 3 or key2 < 3) and (key3 < 100);
204+
(key1 < 3 or key2 < 3) and (key3 < 90);
205205

206206
# this even can cause "all" scan:
207207
if ($index_merge_random_rows_in_EXPLAIN)
@@ -228,24 +228,24 @@ if ($index_merge_random_rows_in_EXPLAIN)
228228
--replace_column 9 #
229229
}
230230
explain select * from t0 where
231-
((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4))
231+
((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
232232
or
233-
key1 < 7;
233+
key1 < 5;
234234

235235
select * from t0 where
236-
((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4))
236+
((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
237237
or
238-
key1 < 7;
238+
key1 < 5;
239239

240240
# tree_or(List<SEL_IMERGE>, List<SEL_IMERGE>).
241241
if ($index_merge_random_rows_in_EXPLAIN)
242242
{
243243
--replace_column 9 #
244244
}
245245
explain select * from t0 where
246-
((key1 < 4 or key2 < 4) and (key3 <5 or key5 < 4))
246+
((key1 < 3 or key2 < 3) and (key3 <4 or key5 < 4))
247247
or
248-
((key5 < 5 or key6 < 6) and (key7 <7 or key8 < 4));
248+
((key5 < 5 or key6 < 5) and (key7 <5 or key8 < 3));
249249

250250
if ($index_merge_random_rows_in_EXPLAIN)
251251
{
@@ -270,9 +270,9 @@ if ($index_merge_random_rows_in_EXPLAIN)
270270
--replace_column 9 #
271271
}
272272
explain select * from t0 where
273-
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
273+
((key3 <4 or key5 < 3) and (key1 < 3 or key2 < 3))
274274
or
275-
(((key3 <7 and key7 < 6) or key5 < 2) and (key5 < 5 or key6 < 6));
275+
(((key3 <5 and key7 < 5) or key5 < 2) and (key5 < 4 or key6 < 4));
276276

277277
if ($index_merge_random_rows_in_EXPLAIN)
278278
{
@@ -303,14 +303,14 @@ explain select * from t0 force index(i1, i2, i3, i4, i5, i6 ) where
303303
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
304304

305305
# 8. Verify that "order by" after index merge uses filesort
306-
select * from t0 where key1 < 5 or key8 < 4 order by key1;
306+
select * from t0 where key1 < 4 or key8 < 3 order by key1;
307307

308308
if ($index_merge_random_rows_in_EXPLAIN)
309309
{
310310
--replace_column 9 #
311311
}
312312
explain
313-
select * from t0 where key1 < 5 or key8 < 4 order by key1;
313+
select * from t0 where key1 < 4 or key8 < 3 order by key1;
314314

315315
# 9. Check that index_merge cost is compared to 'index' where possible
316316
create table t2 like t0;
@@ -476,6 +476,10 @@ select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4
476476
and (B.key1 < 500000 or B.key2 < 3);
477477

478478
update t0 set key1=1;
479+
if ($index_merge_random_rows_in_EXPLAIN)
480+
{
481+
--replace_column 9 #
482+
}
479483
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
480484
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
481485
where (A.key1 = 1 or A.key2 = 1)
@@ -492,16 +496,15 @@ update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500;
492496
# The next query will not use index i7 in intersection if the OS doesn't
493497
# support file sizes > 2GB. (ha_myisam::ref_length depends on this and index
494498
# scan cost estimates depend on ha_myisam::ref_length)
495-
--replace_column 9 #
496-
--replace_result "4,4,4,4,4,4,4" X "4,4,4,4,4,4" X "i6,i7" "i6,i7?" "i6" "i6,i7?"
497-
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
498-
from t0 as A, t0 as B
499-
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
500-
and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
501-
502-
if ($index_merge_random_rows_in_EXPLAIN)
499+
if (!$index_merge_random_rows_in_EXPLAIN)
503500
{
501+
# Too unstable for innodb
504502
--replace_column 9 #
503+
--replace_result "4,4,4,4,4,4,4" X "4,4,4,4,4,4" X "i6,i7" "i6,i7?" "i6" "i6,i7?"
504+
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
505+
from t0 as A, t0 as B
506+
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
507+
and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
505508
}
506509
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
507510
from t0 as A, t0 as B

mysql-test/r/index_merge_innodb.result

+21-33
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ key1 key2 key3 key4 key5 key6 key7 key8
3232
1022 1022 1022 1022 1022 1022 1022 2
3333
1023 1023 1023 1023 1023 1023 1023 1
3434
1024 1024 1024 1024 1024 1024 1024 0
35-
explain select * from t0 where key1 < 3 or key2 <4;
35+
explain select * from t0 where key1 < 3 or key2 <3;
3636
id select_type table type possible_keys key key_len ref rows Extra
3737
1 SIMPLE t0 ALL i1,i2 NULL NULL NULL # Using where
3838
explain
@@ -56,7 +56,7 @@ id select_type table type possible_keys key key_len ref rows Extra
5656
explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50;
5757
id select_type table type possible_keys key key_len ref rows Extra
5858
1 SIMPLE t0 ref i1,i2,i3 i3 4 const # Using where
59-
explain select * from t0 use index (i1,i2) where (key1 < 3 or key2 <4) and key3 = 50;
59+
explain select * from t0 use index (i1,i2) where (key1 < 3 or key2 <3) and key3 = 50;
6060
id select_type table type possible_keys key key_len ref rows Extra
6161
1 SIMPLE t0 ALL i1,i2 NULL NULL NULL # Using where
6262
explain select * from t0 where (key1 > 1 or key2 > 2);
@@ -67,7 +67,7 @@ id select_type table type possible_keys key key_len ref rows Extra
6767
1 SIMPLE t0 index_merge i1,i2 i1,i2 4,4 NULL # Using sort_union(i1,i2); Using where
6868
explain
6969
select * from t0 where key1<3 or key2<3 or (key1>5 and key1<8) or
70-
(key1>10 and key1<12) or (key2>100 and key2<110);
70+
(key1>10 and key1<12) or (key2>100 and key2<105);
7171
id select_type table type possible_keys key key_len ref rows Extra
7272
1 SIMPLE t0 ALL i1,i2 NULL NULL NULL # Using where
7373
explain select * from t0 where key2 = 45 or key1 <=> null;
@@ -85,7 +85,7 @@ id select_type table type possible_keys key key_len ref rows Extra
8585
explain select * from t0 where key2=10 or key3=3 or key4 is null;
8686
id select_type table type possible_keys key key_len ref rows Extra
8787
1 SIMPLE t0 index_merge i2,i3 i2,i3 4,4 NULL # Using union(i2,i3); Using where
88-
explain select key1 from t0 where (key1 <=> null) or (key2 < 5) or
88+
explain select key1 from t0 where (key1 <=> null) or (key2 < 3) or
8989
(key3=10) or (key4 <=> null);
9090
id select_type table type possible_keys key key_len ref rows Extra
9191
1 SIMPLE t0 ALL i1,i2,i3,i4 NULL NULL NULL # Using where
@@ -94,26 +94,25 @@ explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or
9494
id select_type table type possible_keys key key_len ref rows Extra
9595
1 SIMPLE t0 index_merge i1,i3,i4 i1,i3 4,4 NULL # Using sort_union(i1,i3); Using where
9696
explain select * from t0 where
97-
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 5 or key6 < 5);
97+
(key1 < 3 or key2 < 3) and (key3 < 3 or key4 < 3) and (key5 < 5 or key6 < 5);
9898
id select_type table type possible_keys key key_len ref rows Extra
9999
1 SIMPLE t0 ALL i1,i2,i3,i4,i5,i6 NULL NULL NULL # Using where
100100
explain
101-
select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
101+
select * from t0 where (key1 < 3 or key2 < 5) and (key1 < 5 or key3 < 3);
102102
id select_type table type possible_keys key key_len ref rows Extra
103103
1 SIMPLE t0 ALL i1,i2,i3 NULL NULL NULL # Using where
104-
select * from t0 where (key1 < 3 or key2 < 6) and (key1 < 7 or key3 < 4);
104+
select * from t0 where (key1 < 3 or key2 < 5) and (key1 < 5 or key3 < 3);
105105
key1 key2 key3 key4 key5 key6 key7 key8
106106
1 1 1 1 1 1 1 1023
107107
2 2 2 2 2 2 2 1022
108108
3 3 3 3 3 3 3 1021
109109
4 4 4 4 4 4 4 1020
110-
5 5 5 5 5 5 5 1019
111110
explain select * from t0 where
112-
(key1 < 3 or key2 < 3) and (key3 < 4 or key4 < 4) and (key5 < 2 or key6 < 2);
111+
(key1 < 3 or key2 < 3) and (key3 < 3 or key4 < 3) and (key5 < 2 or key6 < 2);
113112
id select_type table type possible_keys key key_len ref rows Extra
114113
1 SIMPLE t0 ALL i1,i2,i3,i4,i5,i6 NULL NULL NULL # Using where
115114
explain select * from t0 where
116-
(key1 < 3 or key2 < 3) and (key3 < 100);
115+
(key1 < 3 or key2 < 3) and (key3 < 90);
117116
id select_type table type possible_keys key key_len ref rows Extra
118117
1 SIMPLE t0 ALL i1,i2,i3 NULL NULL NULL # Using where
119118
explain select * from t0 where
@@ -127,26 +126,24 @@ key2 > 5;
127126
id select_type table type possible_keys key key_len ref rows Extra
128127
1 SIMPLE t0 ALL i1,i2,i3 NULL NULL NULL # Using where
129128
explain select * from t0 where
130-
((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4))
129+
((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
131130
or
132-
key1 < 7;
131+
key1 < 5;
133132
id select_type table type possible_keys key key_len ref rows Extra
134133
1 SIMPLE t0 ALL i1,i2,i3 NULL NULL NULL # Using where
135134
select * from t0 where
136-
((key1 < 4 or key2 < 4) and (key2 <5 or key3 < 4))
135+
((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
137136
or
138-
key1 < 7;
137+
key1 < 5;
139138
key1 key2 key3 key4 key5 key6 key7 key8
140139
1 1 1 1 1 1 1 1023
141140
2 2 2 2 2 2 2 1022
142141
3 3 3 3 3 3 3 1021
143142
4 4 4 4 4 4 4 1020
144-
5 5 5 5 5 5 5 1019
145-
6 6 6 6 6 6 6 1018
146143
explain select * from t0 where
147-
((key1 < 4 or key2 < 4) and (key3 <5 or key5 < 4))
144+
((key1 < 3 or key2 < 3) and (key3 <4 or key5 < 4))
148145
or
149-
((key5 < 5 or key6 < 6) and (key7 <7 or key8 < 4));
146+
((key5 < 5 or key6 < 5) and (key7 <5 or key8 < 3));
150147
id select_type table type possible_keys key key_len ref rows Extra
151148
1 SIMPLE t0 ALL i1,i2,i3,i5,i6,i7,i8 NULL NULL NULL # Using where
152149
explain select * from t0 where
@@ -162,9 +159,9 @@ or
162159
id select_type table type possible_keys key key_len ref rows Extra
163160
1 SIMPLE t0 ALL i1,i2,i3,i5,i6 NULL NULL NULL # Using where
164161
explain select * from t0 where
165-
((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
162+
((key3 <4 or key5 < 3) and (key1 < 3 or key2 < 3))
166163
or
167-
(((key3 <7 and key7 < 6) or key5 < 2) and (key5 < 5 or key6 < 6));
164+
(((key3 <5 and key7 < 5) or key5 < 2) and (key5 < 4 or key6 < 4));
168165
id select_type table type possible_keys key key_len ref rows Extra
169166
1 SIMPLE t0 ALL i1,i2,i3,i5,i6,i7 NULL NULL NULL # Using where
170167
explain select * from t0 where
@@ -185,18 +182,16 @@ or
185182
((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
186183
id select_type table type possible_keys key key_len ref rows Extra
187184
1 SIMPLE t0 ALL i1,i2,i3,i5,i6 NULL NULL NULL # Using where
188-
select * from t0 where key1 < 5 or key8 < 4 order by key1;
185+
select * from t0 where key1 < 4 or key8 < 3 order by key1;
189186
key1 key2 key3 key4 key5 key6 key7 key8
190187
1 1 1 1 1 1 1 1023
191188
2 2 2 2 2 2 2 1022
192189
3 3 3 3 3 3 3 1021
193-
4 4 4 4 4 4 4 1020
194-
1021 1021 1021 1021 1021 1021 1021 3
195190
1022 1022 1022 1022 1022 1022 1022 2
196191
1023 1023 1023 1023 1023 1023 1023 1
197192
1024 1024 1024 1024 1024 1024 1024 0
198193
explain
199-
select * from t0 where key1 < 5 or key8 < 4 order by key1;
194+
select * from t0 where key1 < 4 or key8 < 3 order by key1;
200195
id select_type table type possible_keys key key_len ref rows Extra
201196
1 SIMPLE t0 ALL i1,i8 NULL NULL NULL # Using where; Using filesort
202197
create table t2 like t0;
@@ -361,8 +356,8 @@ from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
361356
where (A.key1 = 1 or A.key2 = 1)
362357
and (B.key1 = 1 or B.key2 = 1);
363358
id select_type table type possible_keys key key_len ref rows Extra
364-
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL 1021 Using union(i1,i2); Using where
365-
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL 1021 Using union(i1,i2); Using where; Using join buffer (Block Nested Loop)
359+
1 SIMPLE A index_merge i1,i2 i1,i2 4,4 NULL # Using union(i1,i2); Using where
360+
1 SIMPLE B index_merge i1,i2 i1,i2 4,4 NULL # Using union(i1,i2); Using where; Using join buffer (Block Nested Loop)
366361
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
367362
from t0 as A force index(i1,i2), t0 as B force index (i1,i2)
368363
where (A.key1 = 1 or A.key2 = 1)
@@ -371,13 +366,6 @@ max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.ke
371366
8194
372367
alter table t0 add filler1 char(200), add filler2 char(200), add filler3 char(200);
373368
update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500;
374-
explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
375-
from t0 as A, t0 as B
376-
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
377-
and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
378-
id select_type table type possible_keys key key_len ref rows Extra
379-
1 SIMPLE A index_merge i1,i2,i3,i4,i5,i6,i7?,i8 i2,i8 4,4 NULL # Using union(i2,i8); Using where
380-
1 SIMPLE B index_merge i1,i2,i3,i4,i5,i6,i7?,i8 i2,i8 4,4 NULL # Using union(i2,i8); Using where; Using join buffer (Block Nested Loop)
381369
select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
382370
from t0 as A, t0 as B
383371
where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)

0 commit comments

Comments
 (0)