Skip to content

Commit 56365ce

Browse files
committed
Bug#33275457: Fix multi-valued index
Patch #3: Multi-value indexes are not used for MEMBER OF combined with OR. If we have a MEMBER OF predicate that is combined with other predicates with an OR operator, the range optimizer will not consider MEMBER OF as a candidate for using an index. Fixed by adding a case construct for Item_func::MEMBER_OF_FUNC in get_func_mm_tree(). json_overlaps() and json_contains() already has this type of support. This is a contribution by Yubao Liu. Change-Id: I1fd7a78091998437310973b3c24099ad554a58a6
1 parent 236a31e commit 56365ce

File tree

5 files changed

+471
-26
lines changed

5 files changed

+471
-26
lines changed

mysql-test/r/hash_join.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,11 @@ test.t2 analyze status OK
812812
EXPLAIN FORMAT=tree SELECT t1.col_int_key AS field1, t2.col_int AS field2 FROM t2
813813
JOIN t1 ON 1 WHERE (CAST("1" AS JSON) MEMBER OF( t1.col_json->'$[*]'));
814814
EXPLAIN
815-
-> Inner hash join (no condition) (cost=*** rows=5)
815+
-> Inner hash join (no condition) (cost=*** rows=10)
816816
-> Table scan on t2 (cost=*** rows=5)
817817
-> Hash
818-
-> Filter: json'"1"' member of (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)) (cost=*** rows=1)
819-
-> Index lookup on t1 using mv_idx (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)=json'"1"') (cost=*** rows=1)
818+
-> Filter: json'"1"' member of (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)) (cost=*** rows=2)
819+
-> Index lookup on t1 using mv_idx (cast(json_extract(col_json,_utf8mb4'$[*]') as char(40) array)=json'"1"') (cost=*** rows=2)
820820

821821
SELECT t1.col_int_key AS field1, t2.col_int AS field2 FROM t2
822822
JOIN t1 ON 1 WHERE (CAST("1" AS JSON) MEMBER OF( t1.col_json->'$[*]'));

0 commit comments

Comments
 (0)