我们在 spring jdbc 模板中有一个 sql 来获取数百万条记录,我们想用 Java 处理这些记录。有没有办法使用更少的内存来做同样的事情?
最佳答案
您可能对以下内容感兴趣:
JdbcTemplate.setFetchSize(int fetchSize)
从文档:
Set the fetch size for this JdbcTemplate. This is important for processing large result sets: Setting this higher than the default value will increase processing speed at the cost of memory consumption; setting this lower can avoid transferring row data that will never be read by the application.
Default is 0, indicating to use the JDBC driver's default.
关于java - 如何在spring jdbc模板中制作流式sql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52542824/