Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-13263

Add note to "Multiple Join Conditions with $lookup" on index usage

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • None
    • manual
    • None
    • ServerDocs2020: Aug24 - Aug31, ServerDocs2020: Aug31 - Sep07, ServerDocs2020: Sep8 - Sep14
    • true

    Description

      Description

      When using aggregation with $lookup using a pipeline stage:

      https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/#specify-multiple-join-conditions-with-lookup

       

      We should add a note that $expr will only use indexes on the "from" collection for EQUALITY matches ONLY.  In the example, it will only use an index on "warehouses.stock_item".  It's unable to use it for the range component (warehouses.instock).

       

      Details here: https://jira.mongodb.org/browse/HELP-11242?focusedCommentId=2407968&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2407968

       

      I bring this to your attention since it can have profound performance implications when using $lookup.

       

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

      Attachments

        Activity

          People

            jason.price@mongodb.com Jason Price
            shakir.sadikali@mongodb.com Shakir Sadikali
            Andrew Feierabend Andrew Feierabend (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              2 years, 2 weeks, 4 days ago