Description: Batch updates in MySQL.
Key points:
- in application.properties set spring.jpa.properties.hibernate.jdbc.batch_size
- in application.properties set spring.jpa.properties.hibernate.generate_statistics
(just to check that batching is working)
- in application.properties set JDBC URL with rewriteBatchedStatements=true
(optimization for MySQL)
- in application.properties set JDBC URL with cachePrepStmts=true
(enable caching and is useful if you decide to set prepStmtCacheSize
, prepStmtCacheSqlLimit
, etc as well; without this setting the cache is disabled)
- in application.properties set JDBC URL with useServerPrepStmts=true
(this way you switch to server-side prepared statements (may lead to signnificant performance boost))\
- before Hibernate 5, we need to set in application.properties a setting for enabling batching for versioned entities during update
and delete operations (entities that contains @Version
for implicit optimistic locking). This setting is: spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true
. Starting with Hibernate 5, this setting should be true
by default.