-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
ALL
-
QE 2022-04-04, QE 2022-04-18
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" : 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" : 11, "a" : [ 2, 1 ] },
{ "_id" : 2, "a" : [ 1, 2 ], "y" : 3 },
{ "_id" : 11, "a" : [ 2, 1 ] }] }