(classic) Add a small foreign collection result cache to $lookup for repeat localField values

XMLWordPrintableJSON

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

      In classic $lookup, we query the foreign collection for each incoming localField value. This involves reconstructing and optimizing the foreign collection query for each new value. However often there are repeat localField values, which means the foreign query results will be the same if there are no let variables.

      We can have a small LRU cache for the previous localField values, and only store the results if they are small (a few kb). This is beneficial when the number of distinct localField values is low, or when the localField values are arriving in sorted order (the local side query is using an index on the local field). We can skip this optimization for any tricky cases, like arrays.

            Assignee:
            Kristina Znam
            Reporter:
            Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: