[SERVER-60484] Optimize field paths more generally Created: 06/Oct/21  Updated: 19/Oct/21  Resolved: 19/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Yoon Soo Kim Assignee: Yoon Soo Kim
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-60234 Implement plumbing for getField() pus... Closed
Sprint: QE 2021-10-18, QE 2021-11-01
Participants:

 Description   

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.



 Comments   
Comment by Yoon Soo Kim [ 19/Oct/21 ]

Close this ticket in favor of SERVER-60234.

Generated at Thu Feb 08 05:49:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.