Allow $match move before stages that do not rename or modify any paths

XMLWordPrintableJSON

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

      Investigate if we can always move $match stages ahead of stages that do not modify or rename any paths (getModifiedPaths() == {DocumentSource::GetModPathsReturn::Type::kFiniteSet, {}, {}}) (4 stages) and have canSwapWithMatch == true (15 stages).

      Currently, this decision depends on the result of the hasOnlyRenameableMatchExpressionChildren() function which examines the content of a $mach stage and might return false, in which case the $match stage will not be moved. SERVER-73914 decreased the number of such expressions and more expressions are to be addressed with SERVER-55492, however, it is not clear if this is necessary when the modified paths by the previous stage are empty.

      If we can always move $match ahead of stages that do not modify any paths, we should remove the workaround introduced by SERVER-91406.

            Assignee:
            Unassigned
            Reporter:
            Romans Kasperovics
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: