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

Unexpected behavior of query planner with sparse indices

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.1
    • Component/s: Querying
    • None

      I am running mongodb version 2.6.1. I have a sparse index on testField. This query:

      db.testCollection.find({ testField: "123"})

      uses my index. This query:

      db.testCollection.find( {testField: { $exists: true } })

      does this as well. But this query:

      db.testCollection.find({ testField: {$ne: null } })

      perform a full collection scan. According to the documentation: "If a sparse index results in an incomplete result set for queries and sort operations, MongoDB will not use that index". But i don't understand why is the third query result set can't be obtained from the sparse index in my db.
      Is this a bug or am i doing something wrong?

            Assignee:
            Unassigned Unassigned
            Reporter:
            nameless.twice@gmail.com Sergey Isaev
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: