$lookup should cache query results

XMLWordPrintableJSON

    • Query Optimization
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If you are doing an aggregation on a large collection, and your aggregation contains a $lookup stage which queries a smaller collection (think <= 100 documents), the $lookup stage will issue a query for each document in the larger collection.

      The $lookup stage should cache the results of the query to avoid unnecessary work in situations like this.

      Original Description

      I have tried the $lookup aggregator and the performance was not as expected.
      I have one collection with about 350K documents and one with 100 documents.
      There are two indexes on the “localfield” and on the “foreignfield”.
      I am trying to join the first collection with the second.

      After an exchange of emails with Norberto : "it looks like it is not using either indexes, and therefore it's taking so long. "

      Please find above the link to test:
      https://github.com/bappr/lookup-test

              Assignee:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Benjamin Appréderisse
              Votes:
              12 Vote for this issue
              Watchers:
              34 Start watching this issue

                Created:
                Updated: