-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Blocker - P1
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
None
-
None
-
None
-
None
-
None
-
None
-
None
If there is a null or a missing value either in the data or in the predicate, and the index is descending, the numKeysEstimate value is zero . This is different from SERVER-109336 where the cardinalityEstimate is incorrect but the numKeysEstimate is correct.
To reproduce:
db.foo.drop();
db.foo.insertMany([
{a: null}, // Or missing
{a: 1}
]);
db.foo.createIndex({a: -1});
// Returns 1 row
db.foo.find({a:{$ne: 1}});
// Returns 0
db.foo.find({a:{$ne: 1}}).explain().queryPlanner.winningPlan.inputStage.numKeysEstimate;
// Returns 1 row
db.foo.find({a:{$ne: null}});
// Returns 0
db.foo.find({a:{$ne: null}}).explain().queryPlanner.winningPlan.inputStage.numKeysEstimate;
- is related to
-
SERVER-109891 samplingCE: cardinalityEstimate is zero for $type
-
- In Progress
-
- related to
-
SERVER-109336 samplingCE: cardinalityEstimate is incorrect for $ne
-
- Backlog
-