[SERVER-65153] Duplicated results when INLJ is used for $lookup in SBE Created: 31/Mar/22  Updated: 29/Oct/23  Resolved: 04/Apr/22

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

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

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QE 2022-04-04, QE 2022-04-18
Participants:

 Description   

no indexes on the foreign collection "r", NLJ is used:
db.l.aggregate({$lookup: {from:"r", localField:"b", foreignField:"a", as:"matched"}})
{ "_id" : 0,
"b" : [ 1, 2 ],
"matched" : [

{ "_id" : 2, "a" : [ 1, 2 ], "y" : 3 }

,

{ "_id" : 11, "a" : [ 2, 1 ] }

]
}

db.r.createIndex(

{a:1}

) // this enables INLJ strategy for the lookup
db.l.aggregate({$lookup: {from:"r", localField:"b", foreignField:"a", as:"matched"}})
{ "_id" : 0,
"b" : [ 1, 2 ],
"matched" : [

{ "_id" : 2, "a" : [ 1, 2 ], "y" : 3 }

,

{ "_id" : 11, "a" : [ 2, 1 ] }

,

{ "_id" : 2, "a" : [ 1, 2 ], "y" : 3 }

,

{ "_id" : 11, "a" : [ 2, 1 ] }

] }



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

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: SERVER-65153 Deduplicate foreign documents returned from index join
Branch: master
https://github.com/mongodb/mongo/commit/c32836e8fb5e71cb334c7517aeeabe5a9bda971a

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