Consider removing ProjectionExecutor::optimize()

XMLWordPrintableJSON

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

      Consider projection_ast::Projection and projection_executor::ProjectionExecutor classes.

      Projection AST is a logical representation of a projection.

      ProjectionExecutor is an execution class that accepts an AST can can execute it on a document in Classic engine.

      Currently both have optimize() methods that traverse the projection tree and call optimize() on any expressions found:

      Executor: https://github.com/mongodb/mongo/blob/cd90f28f0a69ab94a913fb5310a69a7602e2f107/src/mongo/db/exec/projection_node.cpp#L335

      AST:

      https://github.com/mongodb/mongo/blob/cd90f28f0a69ab94a913fb5310a69a7602e2f107/src/mongo/db/query/compiler/logical_model/projection/projection.cpp#L77

       

      This seems like a needless code duplication. 

      Because ProjectionExecutor is purely execution class, we must consider to remove optimization logic from it.

      Maybe it is better if it will execute an AST exactly as given and we should ensure that we always construct it from already optimized AST.

            Assignee:
            Unassigned
            Reporter:
            Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: