db.orders.aggregate([
{ $match: { status: "paid" } },
{ $group: { _id: "$country", revenue: { $sum: "$total" }, orders: { $sum: 1 } } },
{ $sort: { revenue: -1 } }
])`$match` early in the pipeline can reduce the amount of work later stages perform.