-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Integration
-
None
-
None
-
None
-
None
-
None
-
None
-
None
The unpack bucket stage first checks if any rewrites are possible , if so, does push downs, and only after this tries to optimize the end of the pipeline. This results in sub-optimal scenarios. For example, for `db.coll.aggregate([\{$sort: {"m": 1}}, \{$skip: 1}, \{$limit: 1}])`, `$sort` gets pushed down before `_internalUnpackBucket` instead of topKSort. However, in cases such as
db.coll.aggregate([
{
"$match": {
"$nor": [
{"t": {"$in": []}},
]
}
},
{"$sort": {"m": 1}},
{"$skip": 1},
{"$limit": 1}
]
)
topKSort is pushed down because the presence of `$match` stage between `_internalUnpackBucket` and `$sort` results in the optimization of the end of the pipeline.
- is related to
-
SERVER-101866 $alwaysFalse not pushed down in time series unpack bucket
-
- Backlog
-
- related to
-
SERVER-100299 sort-skip-limit may return more documents than limit specifies
-
- Closed
-