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

[CQF] Consider the expression child of an EvaluationNode when determining its cost

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

      Currently the cost of EvaluationNode is a function of its child's cardinality estimate, the startup cost + marginal cost coefficients. The number/depth of path elements in the node is not considered.

      This led to confusion in the implementation of SERVER-79034, see discussion here, where two alternatives were computed to have identical cost, despite one plan known to be better.

      Here are some simplified plan snippets which demonstrate the problem. Both plans generate a projection for "a.b", one doing as an explicit projection while the other pushing the projection of "a" into the PhysicalScan. But both have the same cardinality estimates and the same number of Evaluation nodes, and thus end up with the same cost.

       

      Evaluation [{proj_a_b}]
      |  EvalPath []
      |  |  Variable [root]
      |  PathGet [a]
      |  PathGet [b]
      |  PathIdentity
      PhysicalScan [{'<root>': root}]
      Evaluation [{proj_a_b}]
      | EvalPath []
      | | Variable [proj_a]
      | PathGet [b]
      | PathIdentity
      PhysicalScan [{'<root>': root, 'a': proj_a}]

       

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: