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

when $count is at the end of multiple stages that don't change the number of documents in pipeline, those stages can be eliminated

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Query Optimization

      Something that looks like this:

      {$match:{}},
      {$project:{}},
      {$lookup:{}},
      {$addFields:{}},
      {$lookup:{}},
      {$count:"c"}
      

      is basically a $match followed by a $count. It would be nice if aggregation had a way of figuring that out.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            1 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: