如何在hibernate中启用批处理插入? [英] How do you enable batch inserts in hibernate?
问题描述
使用hibernate时,当我尝试使用
启用批次插入时, 50< / property>我得到以下输出:
[...] cfg.SettingsFactory INFO - 版本化数据的JDBC批量更新:disabled
[...] cfg.SettingsFactory INFO - 批处理的SQL插入:disabled
然后:
[...] jdbc.AbstractBatcher DEBUG - 执行批处理大小:1
基本上
我缺少一个设置?
发现在这种情况下缺少的是:
< property name =order_inserts> true< / property>
ref: https://forum.hibernate.org/viewtopic.php?p=2374413 , http://stackoverflow.com/a/5240930/32453
或者可能是hibernate.order_inserts。
现在我看到了
[...] cfg.SettingsFactory INFO - 用于批处理的订单SQL插入:启用
...
[ ...]执行批处理大小:2
jdbc:mysql:
hibernate.jdbc.batch_versioned_data也可能有用。 / localhost:3306 / batch?rewriteBatchedStatements = true类型连接字符串也可能以某种方式相关。
https://forum.hibernate.org/viewtopic.php?p=2374413 ,还可以查看
休眠批量大小混乱
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?
Turns out what was missing in this case was:
<property name="order_inserts">true</property>
ref: https://forum.hibernate.org/viewtopic.php?p=2374413, http://stackoverflow.com/a/5240930/32453 Or possibly hibernate.order_inserts.
Now I see
[...] cfg.SettingsFactory INFO - Order SQL inserts for batching: enabled
...
[...] Executing batch size: 2
Much more frequently (anything greater than 1 basically means it's successfully doing batch inserts).
hibernate.jdbc.batch_versioned_data may also be useful.
jdbc:mysql://localhost:3306/batch?rewriteBatchedStatements=true type connection strings might also be related somehow.
https://forum.hibernate.org/viewtopic.php?p=2374413 and also see Hibernate batch size confusion
这篇关于如何在hibernate中启用批处理插入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!