[SERVER-65489] Investigate replacing terminal unwind of foreign key in $lookup with a conditional one Created: 12/Apr/22  Updated: 29/Oct/23  Resolved: 25/Apr/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.0.0-rc2, 6.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Irina Yatsenko (Inactive) Assignee: Irina Yatsenko (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.0
Sprint: QE 2022-05-02
Participants:

 Description   

Currently, if the terminal value in the foreign key is a scalar, we'll add the scalar to the stream of foreign key values twice, first from the unwind and then as a "whole value". We should investigate whether making the unwind conditional on the terminal being an array would improve perf of NLJ.



 Comments   
Comment by Githook User [ 25/Apr/22 ]

Author:

{'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}

Message: SERVER-65489 Make unwind of the terminal foreign key value conditioned on whether the value is an array

(cherry picked from commit 55c81877e5c873f0aa66603552ea4bab8e5caec9)
Branch: v6.0
https://github.com/mongodb/mongo/commit/03c459860f88e55b6842583f857d00346a1af11d

Comment by Irina Yatsenko (Inactive) [ 22/Apr/22 ]

The change provides a considerable performance improvement (up to 30% in some micro-benchmarks) in $lookup queries with scalar foreign keys.

Comment by Githook User [ 22/Apr/22 ]

Author:

{'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}

Message: SERVER-65489 Make unwind of the terminal foreign key value conditioned on whether the value is an array
Branch: master
https://github.com/mongodb/mongo/commit/55c81877e5c873f0aa66603552ea4bab8e5caec9

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