Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
允许多个in组合条件命中索引
例如索引: key idx_abcd(
a
,b
,c
,d
), 条件:a in ("a1", "a2") and (b , c) in (("b1", "c1"), ("b2","c2")), 会匹配索引a,b,c三个字段条件a全匹配被裁剪,条件(b, c)全部字段匹配索引索引被裁剪,裁剪后的条件会被组合展开为索引的ranges:
若一个字段对应多个in表达式,则只会使用一个,例如:(a , b) in (("a1", "b1"), ("a2","b2")) and (b , c) in (("b1", "c1"), ("b2","c2"), ("b3","c3")), b字段同时对应了2个in条件,则b字段只会使用in的值较少的一个,本例为会使用(a,b)
(a,b)全部字段匹配索引将会被裁剪掉,(b, c)只会索引匹配字段c,条件会被保留,但记录("b3", "c3")将会被裁剪掉。索引的ranges将被展开为:
相关测试用例,可以用explain format='plan' select ... 进行分析: