Move $unwind up so it can be absorbed by $lookup

XMLWordPrintableJSON

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

      Consider a query like:

      [
          { $lookup: {
              from: "b",
              ...
              as: "y"
          }},
          { $lookup: {
              from: "a",
              ...
              as: "x"
          }},
          { $unwind: "$y" },
          { $unwind: "$x" },
        ]

      Recently I asked Claude to generate a query, which actually ended up being near join-eligible but wasn't because of the placement of the $unwinds. I suspect this would be a beneficial rewrite regardless of join-optimization. Example prompt/query in comments.

            Assignee:
            Unassigned
            Reporter:
            Alya Berciu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: