Get total number of rows when offset is greater than max
You can adapt something like this:

select c.count, u.*
from
  (
    select count(*) as count
    from users
  ) as c
  left join 
  (
    select name, id
    from users
    order by id
    limit 5 offset 50
  ) as u
  on true
order by u.id
 ;