Below we have a snippet of an aggregate query.
The prior state returns 1065 documents (approximate size 800 bytes each). The lookup uses an index and this collection has only 80 entries, still it takes around 135ms. Why so much?
"nReturned" : NumberLong(1065),
"executionTimeMillisEstimate" : NumberLong(1)
},
{
"$lookup" : {
"from" : "pService",
"as" : "pService",
"let" : {
"sId" : "$serviceIdRef"
},
"pipeline" : [
{
"$match" : {
"$expr" : {
"$eq" : [
"$serviceIdRef",
"$$sId"
]
}
}
},
{
"$project" : {
"pServiceName" : 1.0,
"pServiceDescription" : 1.0,
"_id" : 0.0
}
}
]
},
"totalDocsExamined" : NumberLong(4),
"totalKeysExamined" : NumberLong(4),
"collectionScans" : NumberLong(0),
"indexesUsed" : [
"pService_serviceIdRef"
],
"nReturned" : NumberLong(1065),
"executionTimeMillisEstimate" : NumberLong(135)
},
Thanks.