Hi Cedric,
The syntax to use lookup with pipeline is slightly different as mentioned in the docs - Lookup
I doubt the time consumption is due to the mentioned veryHeavyField but still i think the below modified query may solve your purpose as it in the beginning itself removes the veryHeavyField.
[
{
$match: {
isDeleted: false
},
},
{
$lookup: {
from: "joined",
let: {
id: "$_id"
}
pipeline: [
{
$project: { veryHeavyField: 0 }
},
{
$match: {
$expr: {
$eq: ["$$id", "$sourceId"]
}
}
}
]
as: "joined",
},
}
]
Hope this helps!!