---
title: "Discussion on \"Spring Boot: Boost JPA Bulk Insert Performance by 100x\" | Hashnode"
description: "Discussion on \"Spring Boot: Boost JPA Bulk Insert Performance by 100x\". How to boost JPA bulk insert performance by 100 times."
url: "https://hashnode.com/posts/spring-boot-boost-jpa-bulk-insert-performance-by-100x/60a22e31b66a0b15ebfcaef3"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Spring Boot: Boost JPA Bulk Insert Performance by 100x](https://amrutprabhu.hashnode.dev/spring-boot-boost-jpa-bulk-insert-performance-by-100x?utm_source=hashnode&utm_medium=feed)

How to boost JPA bulk insert performance by 100 times.

May 17, 2021 · 3 min read · amrutprabhu.hashnode.dev  
Read the article

-   [#spring](https://hashnode.com/tag/spring)
-   [#springboot](https://hashnode.com/tag/springboot)
-   [#java](https://hashnode.com/tag/java)
-   [#databases](https://hashnode.com/tag/databases)
-   [#performance](https://hashnode.com/tag/performance)

## Written by

[Amrut Prabhu](https://hashnode.com/@amrutprabhu)

@amrutprabhu

  
[View profile](https://hashnode.com/@amrutprabhu)

Software Craftsman | Tech Enthusiast

## Responses 1

Markdown supported · ⌘↵ to post

[vishnu chilamakuru](https://hashnode.com/@vishnuc)

[May 17, 2021](https://hashnode.com/posts/spring-boot-boost-jpa-bulk-insert-performance-by-100x/60a22e31b66a0b15ebfcaef3/comment/60a29212fad22c2c5faba591)

I think Mysql does support auto increment.. U can use that as well to increment ids..

[vishnu chilamakuru](https://hashnode.com/@vishnuc)

[May 17, 2021](https://hashnode.com/posts/spring-boot-boost-jpa-bulk-insert-performance-by-100x/60a22e31b66a0b15ebfcaef3/comment/60a29212fad22c2c5faba591#reply-60a2aa0e95a5b03004409eb7)

[Amrut Prabhu](https://hashnode.com/@amrutprabhu) no JPA don't need to do select call for `GenerationType.IDENTITY` .

the reason why sequence is fast is because id is generated before transaction commit.

While in IDENTITY type Id is generated during transaction commit phase.

For more details : [baeldung.com/jpa-strategies-when-set-primary-key](https://www.baeldung.com/jpa-strategies-when-set-primary-key)

[Amrut Prabhu](https://hashnode.com/@amrutprabhu)

[May 18, 2021](https://hashnode.com/posts/spring-boot-boost-jpa-bulk-insert-performance-by-100x/60a22e31b66a0b15ebfcaef3/comment/60a29212fad22c2c5faba591#reply-60a38be3eeabf031a1a96461)

[vishnu chilamakuru](https://hashnode.com/@vishnuc) Without a sequence, the IDENTITY would require to do a select while committing.

[vishnu chilamakuru](https://hashnode.com/@vishnuc)

[May 18, 2021](https://hashnode.com/posts/spring-boot-boost-jpa-bulk-insert-performance-by-100x/60a22e31b66a0b15ebfcaef3/comment/60a29212fad22c2c5faba591#reply-60a38fc4eeabf031a1a96506)

[Amrut Prabhu](https://hashnode.com/@amrutprabhu) yes got the clarity now.. It's the issue with hibernate.. Actually for bulk inserts.. Before, I was wondering that when I tried inserting rows to mysql id used to be generated by database.

From a database point of view, this is very efficient because the auto-increment columns are highly optimized, and it doesn’t require any additional statements.

This approach has a significant drawback if you use Hibernate. Hibernate requires a primary key value for each managed entity and therefore has to perform the insert statement immediately. This prevents it from using different optimization techniques like JDBC batching.
