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

SBE project stage requires the child stage to materialize the result

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Query Execution

      In the SBE plans we've recently started generating for time series, if there is $project that does `buildProjectionDefault()` it would require the child stage to produce the kResult slot. It means the plan would look like:

      db.ts.explain().aggregate([{$match: {c: 42}},{$project: {_id: 0, b: 1}}]).queryPlanner.winningPlan.slotBasedPlan.stages // "b" is meta field and "c" is a measurement field
      [3] project [s8 = makeBsonObj(MakeObjSpec(["b"], Closed, ReturnNothing), s7)]
      [2] mkbson s7 [c = s6, b = s4] true false
      [2] filter {traverseF(s6, lambda(l101.0) { ((move(l101.0) == 42L) ?: false) }, false)}
      [2] block_to_row blocks[s5] row[s6]
      [2] ts_bucket_to_cellblock s2 pathReqs[s5 = Get(c)/Id] s4 = meta

      Because a kResult slot is requested, we finish bucket unpacking with a materializing mkbson stage, only to pass it to the project stage which will rematerialize a subset of the fields.

            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            0 Vote for this issue
            2 Start watching this issue