Tighter bounds for literal null checks with sparse indexes

XMLWordPrintableJSON

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

      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:
            [DO NOT USE] Backlog - Query Execution
            Reporter:
            Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: