我正在使用spring data saveAll在Oracle数据库中保存3500条记录,但是执行速度非常慢,有没有办法进行批量插入或其他更快的方法?
noteRepository.saveAll(noteEntityList);//<- this one is slow for 3000 records
提前感谢
发布于 2021-04-20 01:25:46
默认情况下,saveAll不会创建批处理,需要开启批处理。您需要设置以下属性才能启用批处理
spring.jpa.properties.hibernate.jdbc.batch_size=100
spring.jpa.properties.hibernate.order_inserts=true (if inserts)
OR
spring.jpa.properties.hibernate.order_updates=true (if updates)
第一个属性批量收集事务,第二个属性收集按实体分组的语句。
有关更多详细信息,请查看此帖子How to do bulk (multi row) inserts with JpaRepository?
https://stackoverflow.com/questions/67165998
复制相似问题