简体   繁体   中英

Sublist in Arraylist vs limit in SQL

I am working on a grid with pagination.. I have to display 10 rows in a grid each time. So Database may contains max of 1000 rows(mostly wont exceed 500 records).

So will be good to pull all the records and then apply Array.sublist(start, end) OR SQL query with LIMIT(start, end)?

Thanks

The best solution would be to go with offset and limit. Best applications are when you don't cache too much and you are saving resources. Think more stateless, less you store, better your application works.

If you are using Hibernate you can add caches that will store those records (3-rd level cache -for queries), then Hibernate will cache them for you, but this level of cache is also not recommended.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM