TLDR: MongoDB Pagination - Two Approaches You Need to Know
Date: 2017-03-22 Source: https://arpitbhayani.me/blogs/fast-and-efficient-pagination-in-mongodb
Overview
Learn how to efficiently paginate MongoDB data using skip/limit and _id-based methods. Improve performance for batch processing & UI display. MongoDB is a document based data store and hence pagination is one of the most common use case of it.
Key Points
- Showing huge set of results on user interface
- Approach 1: Using
cursor.skipandcursor.limit: MongoDB cursor has two methods that makes paging easy; they are skip(n) will skip n documents from the cursor while limit(n) will cap the number of documents to be returned from the cursor.