index not used when it has partialFilterExpression and $exists on a query subset

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Minor - P4
    • None
    • Affects Version/s: 3.4.9
    • Component/s: None
    • ALL
    • Hide

      See above

      Show
      See above
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Consider the following:

      db.test.insert({a: {b:2}})
      db.test.ensureIndex({
          'a.b': 1
        }, {
          name: 'test_index',
          background: true,
          partialFilterExpression: {
            'a': { $exists: true }
          }
        })
      
      db.test.find({'a.b': 2}).explain(true)
      

      Actual:
      The index is not used (the first execution stage of the explain(true) result is COLLSCAN

      Expected:
      The index is used and IXSCAN shows up in the explain(true) results. This seems logic since the query `'a.b': 1` implies `'a':

      { $exists: true }

      `.

            Assignee:
            Mark Agarunov (Inactive)
            Reporter:
            Brad Vogel
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: