[SERVER-56832] Provide aggregation stage to abort pipeline halfway through Created: 11/May/21  Updated: 12/May/21  Resolved: 12/May/21

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

Type: Improvement Priority: Minor - P4
Reporter: Erikvc Erik Assignee: Edwin Zhou
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-40117 "$exit" aggregation stage (with $cond... Backlog
Participants:

 Description   

We have some slow large aggregation pipelines where a $limit at the end is not sufficient to prevent slow queries, and where a $limit early in the pipeline would give incorrect results.

Hence we want to have a way to limit early but abort the query instantly if this limit is hit:

For example:

 

aggregate([
   { $match: {....}},
   { $imaginaryNewAbortOnCondition: { 
        count: {$gt: 100}, 
        message: "Too many rockets found, please limit the search range"
     }
   },
   { $lookupUnwindOrOtherExpensiveAggregations: {...}},
   { $limit: 100 }
])

I think limit is our main use case but one could also imagine other uses where a more dynamic condition is useful.

 



 Comments   
Comment by Edwin Zhou [ 12/May/21 ]

Hi sflkjdsflksdmfslkdfj@mailinator.com,

Thank you for your report and your clear example. I believe this improvement duplicates SERVER-40117 and will close this ticket. SERVER-40117 describes a new $exit operator that will interrupt the pipeline when certain given conditions are met.

Best,
Edwin

Generated at Thu Feb 08 05:40:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.