Better projection analysis for $replace(With|Root)

XMLWordPrintableJSON

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

      I'm thinking of a query like so:

      db.foo.aggregate([{$replaceWith: "$x"}, {$match: {y: 1}}, {$project: {y: 1}}])
      

      SERVER-72037 describes the work to push the $match before the $replaceWith. But even if that is complete, we would seem to stop our projection/dependency analysis at the $replaceWith stage there and miss that the query only needs "x.y", not all of "x". If "x" had many sub-fields, this could be a dramatic savings.

              Assignee:
              Unassigned
              Reporter:
              Charlie Swanson
              Votes:
              1 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated: