Database

[{"collection":"collection","count":100,"content":{"A":{"type":"int","min":1,"max":25}},"indexes":[{"name":"A_idx","key":{"A":1}}]}]

Query

db.collection.aggregate([{$match:{A:{$gte:2,$lte:7}}},{$set:{B:10}},{$sort:{A:1}},{$limit:5}]).explain("executionStats")

Result