[SERVER-4506] aggregation: optimize by pushing matches to earlier in a pipeline Created: 15/Dec/11  Updated: 11/Nov/19  Resolved: 01/Apr/16

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Benjamin Murphy
Resolution: Duplicate Votes: 5
Labels: bi-performance, optimization, performance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-19153 Conditionally push $match before $pro... Closed
duplicates SERVER-23466 $match should be moved into the query... Backlog
duplicates SERVER-20506 Conditionally order $match with $unwind Closed
duplicates SERVER-21612 Combine post $lookup $match on looked... Closed
Related
related to SERVER-12376 $skip and $limit should be moved befo... Closed
related to SERVER-20506 Conditionally order $match with $unwind Closed
is related to SERVER-447 new aggregation framework Closed
is related to SERVER-20506 Conditionally order $match with $unwind Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 10 (02/22/16), Query 11 (03/14/16), Query 12 (04/04/16)
Participants:

 Description   

An aggregation pipeline using $match should be optimized so that the $match is moved as close as possible to the front of the pipeline, reducing the number of documents passing through each subsequent stage.

Work is planned for the following optimizations, and is tracked in these tickets:

Old Description
This is an optimization we can apply in the future.

Applying matches before other operations allows less work to be done in the pipeline because documents will have been filtered out.

Matches can't be pushed earlier than just anything. For example, a $match can't be pushed ahead of a $skip or $limit, because it will change the results. On the other hand, a $match can be pushed ahead of a $project when it doesn't depend on a computed value in the project – field renames don't alter anything except the references in the $match.

Being able to push matches earlier will allow us to use indexes for the underlying query.


Generated at Thu Feb 08 03:06:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.