-
Type: Improvement
-
Resolution: Unresolved
-
Priority: 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]]