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

Terminate agg optimization after a maximum number of optimization steps

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Labels:
      None
    • Query Optimization

      When optimizing an aggregation pipeline, we may coalesce multiple stages, swap stages, split stages into two, or eliminate stages entirely. When such an optimization occurs, we often step backwards in order to see whether this optimization allows us to perform yet another optimization step that was not previously possible. Although we are confident that as currently implemented, this process will always terminate, it seems like it could be easy to introduce a code change in the future that would prevent termination in some cases.

      In order to make it trivial to prove that agg optimization always terminates, we should only be willing to perform at most some large maximum number of optimization steps. This would involve limiting the number of possible iterations here:

      https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/db/pipeline/pipeline.cpp#L113-L116

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: