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

$lookup should cache query results

    XMLWordPrintable

    Details

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              bappr Benjamin Appréderisse
              Participants:
              Votes:
              6 Vote for this issue
              Watchers:
              20 Start watching this issue

                Dates

                Created:
                Updated: