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

Allow hashed indexes to support $ne queries

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying
    • None
    • Query Optimization

    Description

      When performing a $ne query such as:

      db.getCollection('users').find({ 'name.middle': { '$ne': null } }).hint({'name.middle': 'hashed'}).explain()
      

      I can see a full table scan is being performed before returning the result and the hash index is being ignored.
      In our case, most of the records would have a null value and thus using the index to quickly reach out to the few relevant documents would have been much more efficient.

      To workaround this, we had to resort to using a regular index on top of the more efficient/small hashed index.

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            nmardiks Nir Mardiks
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated: