<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>whenlambo</author><text>Moreover, you can query, like, +3 more, and if the extra is less than 3, return that extra items (short tail) also. This way, you won’t have the last page with 1-2 items only.</text><parent_chain><item><author>therusskiy</author><text>How do you find on the backend if a page is the last one?
The trick I used to avoid extra SQL queries is if a user asks for 10 records I load up to 11 and then return 10. If there were 11 then I return a cursor for the next page, otherwise next page is null.
Is there a better way?</text></item></parent_chain></comment><story><title>Paginating Requests in APIs (2020)</title><url>https://ignaciochiazzo.medium.com/paginating-requests-in-apis-d4883d4c1c4c</url></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>drbojingle</author><text>You could ask for a count of records and divide by the page size.</text><parent_chain><item><author>therusskiy</author><text>How do you find on the backend if a page is the last one?
The trick I used to avoid extra SQL queries is if a user asks for 10 records I load up to 11 and then return 10. If there were 11 then I return a cursor for the next page, otherwise next page is null.
Is there a better way?</text></item></parent_chain></comment><story><title>Paginating Requests in APIs (2020)</title><url>https://ignaciochiazzo.medium.com/paginating-requests-in-apis-d4883d4c1c4c</url></story>