You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MDEV-33281 Make BNL() hint work for join_cache_levels from 0 to 3
BNL() hint effectively increases join_cache_level up to 4 if it is set to value less than 4. This commit also makes the BKA() hint override not only `join_cache_bka` optimizer switch but `join_cache_level` as well. I.e., BKA() hint enables BKA and BKAH join buffers both flat and incremental despite `join_cache_level` and `join_cache_bka` setting.
Copy file name to clipboardExpand all lines: mysql-test/main/opt_hints.result
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -353,6 +353,32 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
353
353
1 SIMPLE t13 ref a a 5 test.t12.a 1 100.00 Using index condition; Using where; Using join buffer (flat, BKAH join); Rowid-ordered scan
354
354
Warnings:
355
355
Note 1003 select /*+ QB_NAME(`QB1`) BKA(`t13`@`QB1`) */ `test`.`t12`.`a` AS `a`,`test`.`t12`.`b` AS `b`,`test`.`t13`.`a` AS `a`,`test`.`t13`.`b` AS `b`,`test`.`t13`.`c` AS `c`,`test`.`t13`.`filler` AS `filler` from `test`.`t12` join `test`.`t13` where `test`.`t13`.`a` = `test`.`t12`.`a` and `test`.`t13`.`b` + 1 <= `test`.`t13`.`b` + 1
356
+
# Hint overrides both join_cache_level and optimizer switch
id select_type table type possible_keys key key_len ref rows filtered Extra
361
+
1 SIMPLE t12 ALL NULL NULL NULL NULL 10 100.00 Using where
362
+
1 SIMPLE t13 ref a a 5 test.t12.a 1 100.00 Using index condition; Using where; Using join buffer (flat, BKAH join); Rowid-ordered scan
363
+
Warnings:
364
+
Note 1003 select /*+ BKA(`t12`@`select#1`) BKA(`t13`@`select#1`) */ `test`.`t12`.`a` AS `a`,`test`.`t12`.`b` AS `b`,`test`.`t13`.`a` AS `a`,`test`.`t13`.`b` AS `b`,`test`.`t13`.`c` AS `c`,`test`.`t13`.`filler` AS `filler` from `test`.`t12` join `test`.`t13` where `test`.`t13`.`a` = `test`.`t12`.`a` and `test`.`t13`.`b` + 1 <= `test`.`t13`.`b` + 1
id select_type table type possible_keys key key_len ref rows filtered Extra
369
+
1 SIMPLE t12 ALL NULL NULL NULL NULL 10 100.00 Using where
370
+
1 SIMPLE t13 ref a a 5 test.t12.a 1 100.00 Using index condition; Using where; Using join buffer (flat, BKAH join); Rowid-ordered scan
371
+
Warnings:
372
+
Note 1003 select /*+ BKA(`t12`@`select#1`) BKA(`t13`@`select#1`) */ `test`.`t12`.`a` AS `a`,`test`.`t12`.`b` AS `b`,`test`.`t13`.`a` AS `a`,`test`.`t13`.`b` AS `b`,`test`.`t13`.`c` AS `c`,`test`.`t13`.`filler` AS `filler` from `test`.`t12` join `test`.`t13` where `test`.`t13`.`a` = `test`.`t12`.`a` and `test`.`t13`.`b` + 1 <= `test`.`t13`.`b` + 1
id select_type table type possible_keys key key_len ref rows filtered Extra
377
+
1 SIMPLE t12 ALL NULL NULL NULL NULL 10 100.00 Using where
378
+
1 SIMPLE t13 ref a a 5 test.t12.a 1 100.00 Using index condition; Using where; Using join buffer (flat, BKAH join); Rowid-ordered scan
379
+
Warnings:
380
+
Note 1003 select /*+ BKA(`t12`@`select#1`) BKA(`t13`@`select#1`) */ `test`.`t12`.`a` AS `a`,`test`.`t12`.`b` AS `b`,`test`.`t13`.`a` AS `a`,`test`.`t13`.`b` AS `b`,`test`.`t13`.`c` AS `c`,`test`.`t13`.`filler` AS `filler` from `test`.`t12` join `test`.`t13` where `test`.`t13`.`a` = `test`.`t12`.`a` and `test`.`t13`.`b` + 1 <= `test`.`t13`.`b` + 1
381
+
set join_cache_level = 8;
356
382
# Enable BKA
357
383
set optimizer_switch='join_cache_bka=on';
358
384
EXPLAIN EXTENDED SELECT /*+ NO_BKA(t13) */ * FROM t12, t13
@@ -1175,6 +1201,40 @@ LEFT JOIN t4 ON t4.a4 <> 0) LEFT JOIN t5 ON t5.a5 = t2.a2;
1175
1201
a4 b5
1176
1202
9 0
1177
1203
9 NULL
1204
+
# BNL() hint overrides join_cache_levels from 0 to 3 increasing it to 4
1205
+
set join_cache_level = 1;
1206
+
EXPLAIN
1207
+
SELECT /*+ BNL(t4, t5) */ t4.a4, t5.b5
1208
+
FROM ((t1 LEFT JOIN (t2 JOIN t3 ON t2.a2 = t3.a3) ON t2.b2 = t1.a1)
1209
+
LEFT JOIN t4 ON t4.a4 <> 0) LEFT JOIN t5 ON t5.a5 = t2.a2;
1210
+
id select_type table type possible_keys key key_len ref rows Extra
1211
+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1212
+
1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 1 Using where; Using index
1213
+
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.a3 1 Using where
1214
+
1 SIMPLE t4 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
1215
+
1 SIMPLE t5 hash_ALL PRIMARY #hash#PRIMARY 4 test.t2.a2 1 Using where; Using join buffer (incremental, BNLH join)
1216
+
set join_cache_level = 2;
1217
+
EXPLAIN
1218
+
SELECT /*+ BNL(t4, t5) */ t4.a4, t5.b5
1219
+
FROM ((t1 LEFT JOIN (t2 JOIN t3 ON t2.a2 = t3.a3) ON t2.b2 = t1.a1)
1220
+
LEFT JOIN t4 ON t4.a4 <> 0) LEFT JOIN t5 ON t5.a5 = t2.a2;
1221
+
id select_type table type possible_keys key key_len ref rows Extra
1222
+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1223
+
1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 1 Using where; Using index
1224
+
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.a3 1 Using where
1225
+
1 SIMPLE t4 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
1226
+
1 SIMPLE t5 hash_ALL PRIMARY #hash#PRIMARY 4 test.t2.a2 1 Using where; Using join buffer (incremental, BNLH join)
1227
+
set join_cache_level = 3;
1228
+
EXPLAIN
1229
+
SELECT /*+ BNL(t4, t5) */ t4.a4, t5.b5
1230
+
FROM ((t1 LEFT JOIN (t2 JOIN t3 ON t2.a2 = t3.a3) ON t2.b2 = t1.a1)
1231
+
LEFT JOIN t4 ON t4.a4 <> 0) LEFT JOIN t5 ON t5.a5 = t2.a2;
1232
+
id select_type table type possible_keys key key_len ref rows Extra
1233
+
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1234
+
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 1 Using where
1235
+
1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.a2 1 Using index
1236
+
1 SIMPLE t4 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
1237
+
1 SIMPLE t5 hash_ALL PRIMARY #hash#PRIMARY 4 test.t2.a2 1 Using where; Using join buffer (incremental, BNLH join)
0 commit comments