Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-56832

Provide aggregation stage to abort pipeline halfway through

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Duplicate
    • Affects Version/s: 4.4.6
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      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.

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              edwin.zhou Edwin Zhou
              Reporter:
              sflkjdsflksdmfslkdfj@mailinator.com Erikvc Erik
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: