Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

With hibernate, when I attempt to enable batch inserts with

  <property name="jdbc.batch_size">50</property>

I get the following output:

 [...] cfg.SettingsFactory INFO  - JDBC batch updates for versioned data: disabled
 [...] cfg.SettingsFactory INFO  - Order SQL inserts for batching: disabled

And then this:

 [...] jdbc.AbstractBatcher DEBUG - Executing batch size: 1

never more than batch size: 1 basically.

Am I missing a setting?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
180 views
Welcome To Ask or Share your Answers For Others

1 Answer

To enable batching for both INSERT and UPDATE statements, you need to sett all the following Hibernate properties:

spring.jpa.properties.hibernate.jdbc.batch_size=30
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true

If you can use a SEQUENCE, then you should not use IDENTITY entity identifier generator, since it disables batch fetching.

If you cannot use a SEQUENCE (e.g. MySQL), then try using a separate mechanism to enable batch inserts (e.g. JDBC) instead of using the TABLE generator which does not scale and has a high-performance penalty.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...