Mongodb – How can I optimize this query in mongo db?
Here is the query: const tags = await mongo .collection("positive") .aggregate<{ word: string; count: number }>([ { $lookup: { from: "search_history", localField: "search_id", foreignField: "search_id", as: "history", pipeline: [ { $match: { created_at: { $gt: prevSunday.toISOString() }, }, }, {…