what is best way to paging big Resultset -Java

前端 未结 6 619
伪装坚强ぢ
伪装坚强ぢ 2021-01-19 06:44

i am looking for best aproach from perfomance point of view , to show Resultset on webpage partially , lets say by 10 item per page and if user want to see more result, he p

6条回答
  •  深忆病人
    2021-01-19 07:34

    Since you have "GWT" in your tags, I'll assume your server app is running on Google App Engine (GAE).

    • One approach is to have your first query obtain all results, store them in a DB, show the first 20 and then let the next/prev links pull subsets of the stored data out of the DB. You must remember to delete those results from the DB when your user's session times out!

    • Another approach is to obtain all results on each page view, but skip through the results until you've hit the desired subset of 20, and output only those.

    I think that with GAE underneath, the 2nd approach will work better, unless your query is likely to return more than 1000 results, which GAE won't let you retrieve in one transaction.

    • The best approach, if your data and keys lend themselves to it, would be to pull out the correct 20 data items already at query time. But unless your data has continuously ascending integer keys, this may be hard to do.

提交回复
热议问题