Two configuration settings improve a slow Hibernate batch insert in Spring Boot Data JPA. Without them, saveAll() sends one INSERT per row – even across 10,000 rows. With them, median insertion time drops from 437 ms to 77 ms on the same dataset.
I learned this the hard way. A service I maintained was slow under load, and the root cause was a forgotten Hibernate detail. After fixing it, I shared the finding on LinkedIn – the post reached 102,000 impressions, 514 reactions, and 394 saves. Clearly, this problem affects many developers.
TL;DR – Add hibernate.jdbc.batch_size: 10000 (tune for your load) to your Hibernate properties and ?reWriteBatchedInserts=true to your datasource URL. These two flags enable Hibernate batch flushing and rewrite individual INSERTs into a single multi-row INSERT.…