-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Fully Compatible
-
Query 13 (04/22/16)
It's currently very expensive to perform a $match within the aggregation pipeline. This is mostly because the aggregation pipeline works with Documents, which are incompatible with the current MatchExpression::matchesBSON interface, so we have to construct an entirely new BSONObj to match on. There are two things we could do to make this more efficient:
- Instead of converting the entire Document to BSON, we could only convert the fields needed by the match. For example, if the match was {a: {$gte: 4}}, we would only need the field a from the document.
- We could extend the MatchExpression interface to support matching Documents. A Document is logically equivalent to a BSONObj, so it would just be a matter of adapting the matching to use a different API with the object.
- is duplicated by
-
SERVER-22404 Extend MatchExpression to support matching Documents
- Closed
- is related to
-
SERVER-25304 Allow a MatchExpression to match a Document
- Backlog
-
SERVER-22402 Add dependency tracking to the $match stage
- Closed
- related to
-
SERVER-27213 Two $match stages combine incorrectly, yielding incorrect results.
- Closed
-
SERVER-25911 Tune performance of $match stage
- Closed