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

XMLWordPrintableJSON

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

      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:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Asya Kamsky
              Votes:
              1 Vote for this issue
              Watchers:
              12 Start watching this issue

                Created:
                Updated: