-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Blocker - P1
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
None
-
None
-
None
-
None
-
None
-
None
-
None
The numKeysEstimate is correct, but the cardinalityEstimate is zero.
db.foo.drop(); for (let i = 0; i < 1000; i++) { db.foo.insert({a: i}); db.foo.insert({a: 'X'}); } db.foo.createIndex({a: 1}); db.foo.find({a: { '$type': 'string' } } ).toArray().length; db.foo.find({a: { '$type': 'string' } } ).explain().queryPlanner.winningPlan; db.foo.find({a: { '$type': 'int' } } ).toArray().length; db.foo.find({a: { '$type': 'int' } } ).explain().queryPlanner.winningPlan; { isCached: false, stage: 'FETCH', costEstimate: 0.4352537, cardinalityEstimate: 0, estimatesMetadata: { ceSource: 'Sampling' }, inputStage: { stage: 'IXSCAN', costEstimate: 0.427765, cardinalityEstimate: 0, <<<=== WRONG numKeysEstimate: 1000, estimatesMetadata: { ceSource: 'Sampling' }, filter: { a: { '$type': [ 16 ] } }, keyPattern: { a: 1 }, indexName: 'a_1', isMultiKey: false, multiKeyPaths: { a: [] }, isUnique: false, isSparse: false, isPartial: false, indexVersion: 2, direction: 'forward', indexBounds: { a: [ '[nan, inf]' ] } } }
- is related to
-
SERVER-98371 Reduce allocations when estimating number of index keys of a scan using sampling
-
- In Code Review
-
- related to
-
SERVER-113706 samplingCE: numKeysEstimate is incorrect with missing/null values, $ne, descending index
-
- Open
-
-
SERVER-109336 samplingCE: cardinalityEstimate is incorrect for $ne
-
- Backlog
-
-
SERVER-109877 samplingCE: cardinalityEstimate is incorrect for $regex that is not a perfect prefix match
-
- Backlog
-