Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardMongoDBAggregation pipeline executionSingle-choice MCQ

An aggregation pipeline is [{$match}, {$sort}, {$project}, {$limit}]. Even though $limit appears last in the array, the explain plan shows a bounded top-k sort consuming far less than the full sorted set in memory. What execution-engine behavior produces this?

db.events.aggregate([ { $match: { type: 'click' } }, { $sort: { ts: -1 } }, { $project: { _id: 0, ts: 1, url: 1 } }, { $limit: 10 } ])