0

我正在使用跳过和限制的组合对 mongodb 中的集合进行分页。在快速获取路线中,我将参数设置为 page:2 或 page:3 等等。当它在第 2 页时,我跳过 10 条记录,3 20 条记录,依此类推。

但根据 mongodb 文档

The cursor.skip() method is often expensive because it requires the server to walk from the beginning of the collection or index to get the offset or skip position before beginning to return result. As offset (e.g. pageNumber above) increases, cursor.skip() will become slower and more CPU intensive. With larger collections, cursor.skip() may become IO bound.

现在这让我很困扰。它建议基于范围的导航,但是在我只获取页码的情况下,我实际上如何做到这一点。它如何防止这个进程成为 IO 绑定的?

任何详细/解释的答案?

4

0 回答 0