Hello,
I want to know about the best practices for paginated query on collection.
I am using skip based pagination in application and Graphql as a API layer.
Let’s say there is a User
collection with more than 100K Documents.
So, in Graphql query resolver, I am doing two parallel calls,
- Fetching user document from
User
collection (pagesize: 10 and pagenumber: 1) - Fetching total user document count from
User
collection (db.collection.countDocuments())
These two call will happen for every page (eg. for page: 2, 3, 4, …)
So, My question is that, is this the proper way to handle the paginated query or these two calls (data fetch and count fetch) will add an overhead to the mongodb pod/container?
Note: Here, we want skip based pagination, no cursor based pagination.
Thanks in advance