简体   繁体   English

从 Java 中获取大量 Mysql 数据

[英]Fetching Large Set of Mysql Data from Java

My project is in Spring Boot.我的项目在 Spring Boot 中。 I need to fetch more than 150k of records in one go.我需要一次性获取超过 15 万条记录。 I am using Spring JPA.我正在使用 Spring JPA。

However my result Query is giving GC overhead exception in server.但是我的结果查询在服务器中给出了 GC 开销异常。 Surprisingly when I added a count(*) before fetching the actual records everything is running fine.令人惊讶的是,当我在获取实际记录之前添加一个 count(*) 时,一切都运行良好。

I am in search of a proper logical answer我正在寻找合适的逻辑答案

The query count(*) is very light weight query.查询count(*)是非常轻量级的查询。 this will count the record and return the value only.这将计算记录并仅返回值。 but select query fetches complete data, and here you are fetching 150000 records, which is very very huge, so getting GC overhead exception is obvious.但是select查询取的是完整的数据,这里取的是150000条记录,非常非常大,所以GC开销异常很明显。

so,the solution is:所以,解决方案是:
Either optimize your query, or use pagination or use high end server.优化您的查询,或使用分页或使用高端服务器。

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

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