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

Planner leaves {$exists: true} on a wildcard field to be evaluated post-fetch when using CWI

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

      Consider this example:

      db.test.createIndex({"a.$**": 1})
      // IXSCAN with "$_path" : ["[\"a.b\", \"a.b\"]", "[\"a.b.\", \"a.b/\")"] + FETCH without filter
      db.test.find({'a.b': {$exists: true}}).explain()
      
      db.test.dropIndexes()
      db.test.createIndex({"a.$**": 1, b: 1})
      // IXSCAN with "$_path" : ["[\"a.b\", \"a.b\"]", "[\"a.b.\", \"a.b/\")"] + FETCH with {$exists: true}
      db.test.find({'a.b': {$exists: true}}).explain()
      

      In the above example, this behavior is unlikely to cause significant issues because the index scan already filters out all keys where `a.b` doesn't exist. However, when the wildcard part doesn't come first in the compound index, this behavior can trigger the limitation described in SERVER-83322 and prevent $exists: true from being evaluated using the CWI.

            Assignee:
            Unassigned Unassigned
            Reporter:
            henri.nikku@mongodb.com Henri Nikku
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: