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

Tighter bounds for literal null checks with sparse indexes

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying
    • None
    • Query Execution

    Description

      A small opportunity for optimization on queries using sparse indexes:

      assert.commandWorked(db.c.insert({a: 1}));
      db.c.createIndex({a:1}, {sparse: true});
      db.c.explain().find({a: {$exists: true, $eq: null}});
      

      The bounds we get are:

      {"a": ["[MinKey, MaxKey]"]}
      

      Since the query only searches for literal null, I believe we could use tighter bounds which only include null and undefined (something like [[null, null], [undefined, undefined]]

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: