[SERVER-26510] Terminate agg optimization after a maximum number of optimization steps Created: 06/Oct/16  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Aggregation Framework, Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: David Storch Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Participants:

 Description   

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


Generated at Thu Feb 08 04:12:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.