我有一个带有分页的简单查询的存储库:
Page<MyBean> findMyBeans(String name, Pageable pageable);我的问题是:
分页将限制为20 (默认情况下)对mongo的查询(就像mysql中的限制),或者它将从mongo检索所有数据,并仅向调用者返回20个结果?
谢谢
发布于 2016-08-11 00:03:33
它会将光标限制为20。具体来说,它会创建一个值限制为20的DBCursor,如下所示:
Cursor id=0, ns=test.myCollection, query={ }, numIterated=0, limit=100, readPreference=primary如果您使用Java Mongo DB Driver并将DBCursor声明为:
DBCursor myCursor=myCollection.find().limit(20);所以直接使用MongoDB原生游标是(它在20到20之间迭代)(首先调用20,然后是21-40,依此类推):
Cursor cursor = myCollection.find();
cursor.limit(20);https://stackoverflow.com/questions/38850993
复制相似问题