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

Provide aggregation stage to abort pipeline halfway through

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Minor - P4 Minor - P4
    • None
    • 4.4.6
    • None
    • 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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: