[SERVER-44749] $lookup option to bypass Created: 20/Nov/19  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 4.2.1
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Ben Rotz Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Participants:

 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.



 Comments   
Comment by Carl Champain (Inactive) [ 21/Nov/19 ]

Hi ben@ethika.com,

Thanks for the report.
I'm passing this ticket along to the Query team for further investigation.

Kind regards,
Carl
 

Generated at Thu Feb 08 05:06:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.