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

"$exit" aggregation stage (with $cond operator support)

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Query Optimization

      It would be nice if we could exit out of an Aggregate Pipeline. For example:

      db.books.aggregate([
          {$match:{ _id: ObjectId('5bede977e8dd7e5d5df79dab') }},
          {$limit: 20},
          {$exit: { $cond: [ { $in: ['$genre',['science fiction', 'fantasy']}, true, false ] }},
          {$sort: { created: -1 }} // sort is skipped
      ]);
      

      It would also be nice for debugging longer pipelines:

      db.tapping.aggregate([
          {$match:{ _id: ObjectId('5bede977e8dd7e5d5df79dab') }},
          {$exit: true }, // rest of pipeline would be skipped
          ...
      ]);
      

      Thanks for your consideration.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            jonah@surveyplanet.com Jonah Werre
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: