简体   繁体   English

Spring引导服务从oracle数据库返回大数据集

[英]Spring boot service to return large datasets from oracle database

I have a Spring boot project with JPA hibernate.我有一个带有 JPA 休眠的 Spring 启动项目。

My requirement is to return data from database based on the sql where user can choose to fetch all the records from last 30days.我的要求是根据 sql 从数据库返回数据,用户可以选择从中获取过去 30 天的所有记录。 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.我尝试在我的 jpaRepository 中使用 @Query,但结果需要很长时间才能加载到浏览器上。

Any ideas on how can we make if fast?关于我们如何快速制作的任何想法?

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.您需要在查询数据库时传递一个Pageable对象。

You can refer to the following link for more information on how to achieve it: https://www.baeldung.com/spring-data-jpa-pagination-sorting您可以参考以下链接了解更多关于如何实现它的信息: https : //www.baeldung.com/spring-data-jpa-pagination-sorting

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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