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

Tighter bounds for literal null checks with sparse indexes

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Query Execution

      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]]

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: