Is there a more efficient way of making pagination in Hibernate than executing select and count queries?

Baron Schwartz at MySQLPerformanceBlog.com authored a post about this. I wish there was a magic bullet for this problem, but there isn’t. Summary of the options he presented:

  1. On the first query, fetch and cache all the results.
  2. Don’t show all results.
  3. Don’t show the total count or the intermediate links to other pages. Show only the “next” link.
  4. Estimate how many results there are.

Leave a Comment