翻页是采用limit 加上find 第一页的最后一条的_id 来取出第二页的内容
但是就算把索引都载入内存后 翻过两千万文档后每次翻页都耗时十秒以上
请问还有什么翻页快速的方法么
拜谢 感激不尽
First get the first id of the current page, and then use the following to get all the data of the next page:
db.collection.find({_id: {$gt: current_id}}). skip(page_size). limit(page_size). sort({_id: 1});
I have more than 6 million pieces of data, and it is very fast to use this method. If this is the case for you and it still takes more than ten seconds, it may be that your query conditions are not indexed.
Use skip加limit to turn pages
skip
limit
First get the first id of the current page, and then use the following to get all the data of the next page:
I have more than 6 million pieces of data, and it is very fast to use this method.
If this is the case for you and it still takes more than ten seconds, it may be that your query conditions are not indexed.
Useskip
加limit
to turn pages