7
Thinking about performance, what is the best way to paginate a large amount of data?
I’m currently wearing a List<Produtos>
, keeping around 500 products in it, and using subList(min,max)
, returns what I need. However, I believe that this is not the best solution and I would like to know other alternatives to this problem.
Edit
The idea is to maximize performance between unnecessary queries in the bank, because the maximum pool of the bank is 4.
Do you use Ibernate? Or the data is not in a comic?
– DiegoAugusto
Yes, I’m using Ibernate.
– Matheus
You can use the
setFirstResult
andsetMaxResults
. http://www.baeldung.com/jpa-pagination– DiegoAugusto
Is the object list a result of a filter? Ex: user only wants female products. You are using native SQL or HQL?
– adelmo00
No, it is the result of an SQL in a table, in the select case *.
– Matheus
@adelmo00 In the first screen no, only a Where searching for company. Later in case the customer click, is carried out a filter.
– Matheus
@Matheus will formulate an answer and put later, it will take a while
– adelmo00
Give more context, what are you doing exactly? something like being looking for 500 products but always only displays 50 of them on the page? if your bank has more than 500 products your code already fails because it cannot display >=501?
– BrunoRB
@Brunorb Because it is a pagination, obviously it will not all be displayed at the same time.
– Matheus