Pagination in Google App Engine with Java

后端 未结 4 464
攒了一身酷
攒了一身酷 2021-01-12 11:23

I need to create simple pagination of objects, but when I read manual I found out that query.setRange(5, 10); will fetch 10 objects, even when only 5 objects are needed.

4条回答
  •  [愿得一人]
    2021-01-12 11:48

    Why is it a problem if 10 objects are returned from the database? You will still be returned just the 5 objects that you care about (the first 5 are discarded).

    I'm not asking because I think the setRange method is a solution that scales incredibly well, but it is a simple and reasonable solution that is more than adequate in a good number of cases.

    Are you planning on paging extremely large tables or incorporate expensive joins? If not, I'd be tempted to use setRange as the starting point for your pagination.

提交回复
热议问题