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

$merge should resolve 'let' variables only if they're referenced in the update pipeline

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 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.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            anton.korshunov@mongodb.com Anton Korshunov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: