I'm currently implementing a pagination based on HTTP range header on a Ruby on Rails application, and I'm wondering about SQL performances.
Unlike the traditional page
and per_page
query string params, the range header design allow the server to inform the client about the number of total result in the database. For example:
Content-Range: 0-4/123
Informing that:
- the collection contains 5 records,
- the database contains 123 records.
But I'm wondering about performances. If we use this pagination design, then we have to do 2 SQL requests:
- 1 request to get the 5 items,
- 1 request to get the total number of items.
Am I right? Or is there a way to find both informations without a downside?