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

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

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • None
    • 3
    • 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 Unassigned
            Reporter:
            jess.balint@mongodb.com Jess Balint
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: