Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-21284

$lookup should cache query results

    • Query Optimization

      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:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            bappr Benjamin Appréderisse
            Votes:
            12 Vote for this issue
            Watchers:
            33 Start watching this issue

              Created:
              Updated: