NOTE 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.
上文摘自 MongoDB 3.2.9 的官方文档。文中描述的意思是什么?
query.sort({someField: 1}).limit(10);
实际上是先取了 10
个记录,再排序这 10
条记录的吗?