[SERVER-84728] Allow MatchExpression $or -> $in rewrite to preserve parameters Created: 10/Jan/24  Updated: 02/Feb/24

Status: Investigating
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Ben Shteinfeld Assignee: Alexander Ignatyev
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-83712 Consider removing exact number of ele... Open
is related to SERVER-84338 Top level $or queries may lead to inv... Closed
Assigned Teams:
Query Optimization
Sprint: QO 2024-02-05, QO 2024-02-19
Participants:

 Description   

SERVER-84338 disabled the MatchExpression $or->$in rewrite when the equality predicates are parameters. For example (in pseudo-MQL), {$or: [

{foo: p1}

, {foo: p2}]} cannot be rewritten to {foo: {$in: [p1, p2]}} because InMatchExpression only allows the entire $in operand to be a single parameter. This fixed an edge case in the subplanner which resulted in construction of a residual predicate with incorrect autoparameterization behavior.

Another solution to that problem is to introduce a new MatchExpression or modify the representation of InMatchExpression parameters in order to allow an InMatchExpression to contain an array of parameters and literals.

Some questions we'd need to answer to do this ticket:

  • Is the subplanner case in SERVER-84338 the only one where an array of parameters in $in would occur?
  • If so, is the complexity added by implementing this ticket worth the potential performance gain?

Generated at Thu Feb 08 06:55:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.