Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-84728

Allow MatchExpression $or -> $in rewrite to preserve parameters

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Query Optimization
    • QO 2024-02-05, QO 2024-02-19

    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?

      Attachments

        Activity

          People

            alexander.ignatyev@mongodb.com Alexander Ignatyev
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated: