[SERVER-36765] Tighter bounds for literal null checks with sparse indexes Created: 20/Aug/18  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Ian Boros Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Participants:

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


Generated at Thu Feb 08 04:44:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.