Terminate agg optimization after a maximum number of optimization steps

XMLWordPrintableJSON

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

      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:
            [DO NOT USE] Backlog - Query Optimization
            Reporter:
            David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: