[SERVER-14987] Combine multiple adjacent $match commands into one Created: 21/Aug/14  Updated: 10/Dec/14  Resolved: 21/Aug/14

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

Type: Improvement Priority: Major - P3
Reporter: Jochen Kemnade Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: perfomance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-11184 Perf : merge consecutive calls to $match Closed
Participants:

 Description   

If an aggregation pipeline contains multiple $match commands next to each other, they should be treated like a single $match with the items combined with $and.
I noticed a huge difference (around a factor of 100) when i tried

{$match: {"non-indexed-property": "value"}}, {$match: {"indexed-property": "value"}}

vs.

{$match: {"$and": [{"non-indexed-property": "value"}, {"indexed-property": "value"}]}}



 Comments   
Comment by Stennie Steneker (Inactive) [ 21/Aug/14 ]

Hi Jochen,

This improvement has already been implemented in MongoDB 2.6 as per SERVER-11184.

FYI, there are a number of other aggregation pipeline optimizations in 2.6.

Regards,
Stephen

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