Ninja
Ninja

Reputation: 53

Spring boot service to return large datasets from oracle database

I have a Spring boot project with JPA hibernate.

My requirement is to return data from database based on the sql where user can choose to fetch all the records from last 30days. The data is going to huge in this case.

I tried using @Query in my jpaRepository, but the results are taking forever to load on the browser.

Any ideas on how can we make if fast?

Upvotes: 0

Views: 1896

Answers (1)

Rajvir
Rajvir

Reputation: 108

Instead of loading the whole data in one single go, you can go for Pagination. The backend will take the limit and the offset and make subsequent requests to load more data as is needed.

You'll need to pass an object of Pageable while Querying the database.

You can refer to the following link for more information on how to achieve it: https://www.baeldung.com/spring-data-jpa-pagination-sorting

Upvotes: 1

Related Questions