-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
None
-
None
-
None
-
None
-
None
-
None
-
None
This is a variant of SERVER-111446. That one is about covering queries where a field has a null predicate but is projected out so that the difference between null vs. missing does not matter.
Shard keys treat null vs. missing the same as well, so in this case we can likewise avoid fetching the document even if it has a null-predicate/no non-null predicate.
Repro:
db.a.drop()
db.a.createIndex({a: 1, b: 1, c: 1})
db.adminCommand({
shardCollection: "test.a",
key: { a: 1, b: 1, c: 1 },
});
db.a.explain().find({a: null, b: 0}, {_id: 0, b: 1})
`a` has a null predicate and `c` has no predicate, yet their only user is the shard key so the difference between null vs missing does not matter (note that the index is non-multikey as well, so there is no multi-key ambiguity). `b` is the only field projected in but has a non-null predicate, so the query can be covered.
- related to
-
SERVER-111446 Cover null query when other indexed field doesn't match null
-
- Backlog
-