Open neopostmodern opened 11 months ago
Sample code
db.tags.aggregate([
{
$lookup: {
from: "notes",
localField: "_id",
foreignField: "tags",
let: { tagId: "$_id" },
pipeline: [ { $count: "count" } ],
as: "noteCount"
}
},
{ $unwind: "$noteCount" }
])
keep performance in balance?
db.tags.aggregate([` { $lookup: { from: "notes", localField: "_id", foreignField: "tags", let: { tagId: "$_id" }, pipeline: [{ $count: "count" }], as: "noteCount" } }, { $unwind: '$noteCount' }, { $addFields: { noteCount: '$noteCount.count' } }] ).explain("executionStats")
This would speed up the crazy slow cache-rebuilding on cold devices, plus it could easily be refreshed irregularly.