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

$lookup option to bypass

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • 4.2.1
    • Aggregation Framework
    • None
    • Query Execution

    Description

      It would be nice if there was a way to optionally bypass over a lookup stage based on a value in the document.

      Imagine pipeline of

      A,
      lookup B,
      unwind B,
      lookup C

      Where the relationship is many-to-zero A:B, zero-to-many B:C

      However, if there is no B records found, there is no point to do lookup C. In my scenario, the problem is that because there is no B, then the lookup C attempts to do a match on a null value, and the lookup C collection index is sparse. So the lookup is extremely slow due to no index.

      Could be avoided if there was a way to bypass the lookup based on the current document value.

      Let me know if this is unclear and I can draw up an example.

      Another simpler example might just be A lookup B, where A.value is null, and you don't want to bother doing a lookup against B since A.value is null.

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            ben@ethika.com Ben Rotz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: