-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
ALL
-
-
200
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Consider the followings aggregation pipeline:
{$sort: {a: 1}}.
{$limit: 20},
{$match: {b: {$exists: false}}},
{$count: "num"}
The last $count stage works like projections in terms of enabling covered plans, $limit prevents predicate pushdown optimization for the following $match.
For an index like
{a: 1, b: 1}a full index plan will be generated
stage: 'PROJECTION_DEFAULT', planNodeId: 6, transformBy: { num: true, _id: false }, inputStage: { stage: 'GROUP', planNodeId: 5, inputStage: { stage: 'MATCH', planNodeId: 4, filter: { b: { '$exists': true } }, inputStage: { stage: 'LIMIT', planNodeId: 3, limitAmount: 20, inputStage: { stage: 'PROJECTION_COVERED', planNodeId: 2, transformBy: { b: true, _id: false }, inputStage: { stage: 'IXSCAN', planNodeId: 1, nss: 'test.coll', keyPattern: { a: 1, b: 1 }, indexName: 'a_1_b_1', isMultiKey: false, multiKeyPaths: { a: [], b: [] }, isUnique: false, isSparse: false, isPartial: false, indexVersion: 2, direction: 'forward', indexBounds: { a: [ '[MinKey, MaxKey]' ], b: [ '[MinKey, MaxKey]' ] } } } } } }
And the covered plan becomes possible here since we never check bounds for the field "b"in the IndexBoundBuilder.
- related to
-
SERVER-23229 Projection incorrectly returns null value instead of missing field to user if projection is covered
-
- Backlog
-
-
SERVER-12869 Index null values and missing values differently
-
- Backlog
-