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

Group stage builder produces a project stage when group id is constant

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • QE 2023-03-06
    • 35

      Currently, $count aggregation stage will produce a project stage for the group id, even when the group id is constant.

      For aggregation:

      db.coll.explain().aggregate([{$count: "n"}]).stages[0].$cursor.queryPlanner.winningPlan.slotBasedPlan.stages
      

      It produces:

      [2] mkobj s9 [_id = s6, n = s7] true false
      [2] group [s6] [s7 = sum(1)] spillSlots[s8] mergingExprs[sum(s8)]
      [2] project [s6 = (null ?: null)]
      [1] scan s4 s5 none none none none [] @"e8cac054-9809-447e-94d0-1225895e2c70" true false
      

      The project stage is evaluated for every document and is not necessary.

            Assignee:
            rui.liu@mongodb.com Rui Liu
            Reporter:
            rui.liu@mongodb.com Rui Liu
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: