Spring data save vs saveAll performance : <p>I'm trying to understand why saveAll has better performance than save in the Spring Data repositories. I'm using <code>CrudRepository</code> which can be seen <a href="https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/CrudRepository.html" rel="noreferrer">here</a>.</p>

<p>To test I created and added 10k entities, which just have an id and a random string (for the benchmark I kept the string a constant), to a list. Iterating over my list and calling <code>.save</code> on each element, it took 40 seconds. Calling <code>.saveAll</code> on the same entire list completed in 2 seconds. Calling <code>.saveAll</code> with even 30k elements took 4 seconds. I made sure to truncate my table before performing each test. Even batching the <code>.saveAll</code> calls to sublists of 50 took 10 seconds with 30k. </p>

<p>The simple <code>.saveAll</code> with the entire list seems to be the fastest.</p>

<p>I tried to browse the Spring Data source code but <a href="https://github.com/spring-projects/spring-data-jpa/blob/master/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java" rel="noreferrer">this</a> is the only thing I found of value. Here it seems <code>.saveAll</code> simply iterates over the entire <code>Iterable</code> and calls <code>.save</code> on each one like I was doing. So how is it that much faster? Is it doing some transactional batching internally?</p>
