I have an API with pagination support. While returning a page, I have to set a flag hasNextPage to true or false. How can I set it? If we query the total count before querying, it might reduce the performance of the overall API.
If query has ORDER BY and not using index order metrics.sortCount gives total count.
if resultCount less than LIMIT there is no NextPage. If it is equal there might be NextPage. worst case there may be no nextPage (in that case u get 0 results).
Great. Thank you for the solution. Is there any option to get the count if we are not using ORDER BY? We are using index order.
You need to run separate count query
Okay. Thank you.
I am planning to query the page with limit+1. If the resultCount is same as limit+1, then we will set hasNext to true. And return the result without last entry. Is there any issue in this approach?