$elemMatch object form should simplify to a trivially false expression if possible

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      We already simplify the $element value form to a trivially false expression.

      Compare:

      db.test.find({"a.m":{$elemMatch:{$in:[]}}}).explain(true)
      ...
      winningPlan: { isCached: false, stage: 'EOF', type: 'predicateEvalsToFalse' },
      
      db.test.find({a:{$elemMatch:{m:{$in:[]}}}}).explain(true)
      ...
          winningPlan: {
            isCached: false,
            stage: 'COLLSCAN',
            filter: { a: { '$elemMatch': { '$alwaysFalse': 1 } } },
            direction: 'forward'
          },
      

              Assignee:
              Unassigned
              Reporter:
              Jess Balint
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: