[SERVER-55886] Optimize away unused computed fields Created: 07/Apr/21 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | David Percy | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Assigned Teams: |
Query Optimization
|
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
When we compute a new field from an expression (in a $set / $addFields / $project stage), and then that field is ignored or discarded later, we could avoid computing it in the first place. When optimizing a $set stage, we could use getDependencies() on the pipeline suffix to decide which fields are actually dead code. We could do a similar thing for $group (and $setWindowFields). This may have an even bigger impact, since accumulators and window functions can use a lot of space. |