[SERVER-86194] Improve MatchExpression $or->$in rewrite to handle multiple fields Created: 03/Feb/24 Updated: 06/Feb/24 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Ben Shteinfeld | Assignee: | Militsa Sotirova |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Query Optimization
|
| Participants: |
| Description |
|
Currently the MatchExpression $or->$in rewrite is only capable of collapsing a single field with multiple equality disjunctions into a $in. For example,
is optimized to
This leads to an SBE plan with a large number of unnecessary comparisons. SBE is able to evaluate $in predicates more efficiently by using a hashset, and the interval builder is able to generate index bounds more easily on an $in list. These expressions can be further reduce by allowing the $or->$in rewrite to handle multiple fields. There are two high-value workloads (MatchExpressionWidePredicate and MatchExpressionWidePredicateWithDeepFieldpaths) which could be improved by this optimization. |