Mongo Add account name indexes to query data faster
Analysts are often using Mongo aggregation queries with $lookup , like this one: db.account_object.aggregate([{
$match: {
}}, { $lookup: { "from": "comment_object", let: { authorr: "$name" }, pipeline: [{$match: {$expr: {$and: [{"$eq": ["$author", "$$authorr"]}]}}}], "as": "his_comments" }
}]) Such queries are very slow. Let's run such query when we have ~590.000 comments. Result: 15:32 - Started 15:38 - Ended It is so slow because we using comment_object.author field which is just string, and not indexed ObjectId field.