-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.2.0
-
Component/s: Aggregation Framework
-
Labels:None
-
Query Optimization
Currently, if a $merge stage has the 'let' variables defined, but they're not referenced in the update pipeline, we will still resolve those variables and will pass it down to the update system, even though they're not needed. We also have a default variable `$$new` which is resolved to the entire input document if the user omitted the `let` argument. To maximize performance and reduce the stress on update throughput, we should perform an introspection of the update pipeline when creating a $merge stage and remove all `let' variables which are not used in the update pipeline.
We can also prevent shipping out runtime constants (such as $$NOW and $$CLUSTER_TIME) with every update request if they're also not used in the update pipeline or `let` variables.