Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring data saveAll very slow

i m using spring data saveAll to save 3500 records in an Oracle database but it execute very slowly, is there a way to do bulk insert or any other fast way

 noteRepository.saveAll(noteEntityList);//<- this one is slow for 3000 records

thanks in advance

like image 343
MedMahmoud Avatar asked Feb 07 '26 00:02

MedMahmoud


1 Answers

By default, saveAll does not create batch, the batch processing needs to be enabled. You need to set below properties to enable batch processing

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)

First property collects the transaction in batch and second property collects the statements grouped by entity.

Check this thread for more details How to do bulk (multi row) inserts with JpaRepository?

like image 161
pratap Avatar answered Feb 12 '26 05:02

pratap



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!