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

Optimize field paths more generally

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • QE 2021-10-18, QE 2021-11-01

      We can introduce a slot id to ExpressionFieldPath. If generateExpression find ExpressionFieldPath have a known slot id, it just generates a EVariable expression.

      Two (top and bottom) $group stage builders should collaborate to be able to remove intermediary mkbson stage using the above mechanism.

      1. The topĀ GroupNode stage builder does not ask for the result slot if the bottom node is a GroupNode.
      2. The top GroupNode stage builder builds the bottom node.
      3. The bottom GroupNode does the same thing as usual except it does not add a mkbson stage at the end if the result slot is not requested. Instead, it returns field names and slots for _id and accumulator fields.
      4. The top GroupNode stage builder looks up its fields in the returned field names and slots from the bottom GroupNode. If a field is found, then it updates ExpressionFieldPath with the returned slot id and let generateExpression's ExpressionFieldPath visitor know it.
      5. ExpressionFieldPath visitor will generate a simple variable expression if it finds a slot id set at ExpressionFieldPath.

      Update:
      Introducing a slot id to ExpressionFieldPath would be more general optimization for field paths, not just for $group. Consider the above $group case as just an example. So, changed the title.

            Assignee:
            yoonsoo.kim@mongodb.com Yoon Soo Kim
            Reporter:
            yoonsoo.kim@mongodb.com Yoon Soo Kim
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: