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

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

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

      See above

      Show
      See above

      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 Mark Agarunov
            Reporter:
            brad@mixmax.com Brad Vogel
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: