Count the number of records after pagination

I am using pagination to get just 10 results per page.
My request looks like this:querydsl

query.offset(pageNumber*pageSize).limit(pageSize).list(..);

search.Execution time: 69 ms

      

But I also have to count the total number of pages. So I need to count the whole query

query.count();

count.Execution time: 4187 ms

      

As you can see, the count request takes longer and slows down my user request

So how can I solve this problem?

+3


source to share


1 answer


You can make a separate count-only request which will speed up the process.



0


source







All Articles