Optimize $push in $group to limit array size if followed by $slice of same field

XMLWordPrintableJSON

    • Query Optimization
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If I have a pipeline

      {$group:{_id:"any", a:{$push:"$x"}}}, {$project:{a:{$slice:["$a",0,5]}}}
      

      We can pull in knowledge that only first 5 elements are needed from "a" in $group and stop pushing more elements after we have that many.

              Assignee:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Asya Kamsky
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: