Hi there Community,
We have upgraded our production cluster from Mongo 6 to 8 yesterday. It went really well. Our staging cluster was on Mongo 8 for ages.
Nevertheless, we had trouble with one query that went really REALLY slow. Here was the request :
const deletedStatus = await reportsCollection
.find<SingleRemarkDocument>(
{
project_id: { $in: projectIds },
deleted: { $ne: true },
'status._id': { $in: changes.deleted },
},
{ projection: { status: 1 } }
)
.hint('project_id_type_edit_date')
.toArray();
We cannot explain why. What changed between Mongo 6 and 8 to explain that behavior? This query was taking several hours evaluating the whole collection even if the projectIds arrays was empty …
We were expecting the index to return rapidly no result and then try to take care of the other conditions :
{
deleted: { $ne: true },
'status._id': { $in: changes.deleted },
}
We also tried to use an aggregate doing first the match on project_id and then take care of deleted and status._id, but it behaves poorly too.
Thanks for your help,
Simon