sort skip limit

mongodb, sort skip limit, pipeline -- Выясняем как тут сортировать данные при агрегации

$sort + $limit Memory Optimization

When a sort immediately precedes a limit in the pipeline, the $sort operation only maintains the top n results as it progresses, where n is the specified limit, and MongoDB only needs to store n items in memory. This optimization still applies when allowDiskUse is true and the n items exceed the aggregation memory limit.

Changed in version 2.4: Before MongoDB 2.4, $sort would sort all the results in memory, and then limit the results to n results.

Subscribe to RSS - sort skip limit