---
title: "Comment by vishnu chilamakuru on \"Spring Boot: Boost JPA Bulk Insert Performance by 100x\" | Hashnode"
description: "I think Mysql does support auto increment.. U can use that as well to increment ids.."
url: "https://hashnode.com/posts/spring-boot-boost-jpa-bulk-insert-performance-by-100x/60a22e31b66a0b15ebfcaef3/comment/60a29212fad22c2c5faba591"
---

[Discussion](https://hashnode.com/posts/spring-boot-boost-jpa-bulk-insert-performance-by-100x/60a22e31b66a0b15ebfcaef3)

Comment [Spring Boot: Boost JPA Bulk Insert Performance by 100x](https://hashnode.com/posts/spring-boot-boost-jpa-bulk-insert-performance-by-100x/60a22e31b66a0b15ebfcaef3)

[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..

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

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

Yes, It does support auto-increment. But the catch is, JPA has to make a "select" call to increment the id. Which degrades bulk insert performance.

[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.
