Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

关于 mongodb 的分页查询

$
0
0

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条记录的吗?


Viewing all articles
Browse latest Browse all 14821

Trending Articles