[SERVER-60895] Multiple accumulators on the same field generate a plan with duplicated getField() calls Created: 21/Oct/21 Updated: 06/Dec/22 Resolved: 21/Oct/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Irina Yatsenko (Inactive) | Assignee: | Backlog - Query Execution |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Query Execution
|
||||||||
| Participants: | |||||||||
| Description |
|
Start mongod with "--setParameter internalQueryForceClassicEngine=false --setParameter featureFlagSBEGroupPushdown=true" and run the following query (if $min, $max accumulators aren't enabled yet, replace them with $sum) db.LS.explain().aggregate([\{$group: {_id:"$a", o1:{$min:"$c"}, o2:\{$max:"$c"}}}]).queryPlanner.winningPlan.slotBasedPlan.stages The output will look something like this: [2] mkbson s14 [_id = s7, o1 = s12, o2 = s13] true false Notice the duplicated getField on the same field "c". We should eliminate this inefficiency.
|
| Comments |
| Comment by Irina Yatsenko (Inactive) [ 21/Oct/21 ] | |||||||||||||||||||||||||||||||||||
|
Yoonsoo beat me to it: https://jira.mongodb.org/browse/SERVER-60893 | |||||||||||||||||||||||||||||||||||
| Comment by Irina Yatsenko (Inactive) [ 21/Oct/21 ] | |||||||||||||||||||||||||||||||||||
|
If the query involves duplicated access on a sub-field the plan looks like:
db.LS.explain().aggregate([\{$group: {_id:"$a", o1:{$min:"$e.c"}, o2:\{$max:"$e.c"}}}]).queryPlanner.winningPlan.slotBasedPlan.stages
|