I am developing a pagination on a collection in mongodb using combination of skip and limit. in the express get route, i get params as page:2 or page:3 and so on. When its on page 2, i skip 10 records, on 3 20 records and so on.
But as per the mongodb documentation
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.
Now this bothers me. It suggests range based navigation, but how do i actually do it in my case where i just get the page numbers. and how does it prevents this process to become IO bound?
Any detailed/explained answer?