Support absorbed single-table filters when constructing join graph

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

      After SERVER-115982, the join optimizer does not support translation of a $lookup that has absorbed a single-table filter. This can occur when the query contains a lookup-unwind-match sequence, where the match is only on the “as” field of the lookup. For example:

              [            
                  {
                      $lookup: {
                          from: foreignColl1.getName(),
                          localField: "a",
                          foreignField: "a",
                          as: "foreignColl1",
                      },
                  },
                  {$unwind: "$foreignColl1"},
                  {$match: {"foreignColl1.c": {$eq: "bar"}}},
              ], 

      It should be relatively easy to add support for this. The join graph does not need to be adjusted (as it already supports single-table predicates, just the join graph construction logic. Note that both kinds of lookup syntax (local/foreignField and pipeline) support additional filters.

            Assignee:
            Unassigned
            Reporter:
            Hana Pearlman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: