Spring Boot 和 PostgreSQL 中的更新和删除不是批量的
我正在尝试让我的 Spring boot 应用程序使用批处理模式来创建更新和删除操作。 我已通过以下文章成功完成创建操作:
- https:// vladmihalcea.com/postgresql-multi-row-insert-rewritebatchedinserts-property/
- https://www.baeldung.com/jpa-hibernate-batch-insert-update< /a>
在我的应用程序级别,在代理数据源的帮助下,我可以看到批处理适用于我的所有操作,如下所示:
[-exec-6] SLF4JQueryLoggingListener:20 - {"name":"Batch-Insert-Logger", "connection":33, "time":9, "success":true, "type":"Prepared", "batch":true, "querySize":1, "batchSize":5, "query":["
在 PostgreSQL 级别,我可以看到配置后插入工作这我的数据库连接中的 reWriteBatchedInserts=true 。 我用实际的 PostgreSQL 日志验证了它。
但是,对于更新和删除操作,我仍然可以在日志中看到它没有在 PostgreSQL 级别进行批处理。 为了完成此任务,我需要做任何额外的配置吗?
先感谢您。
I'm trying to get my Spring boot application to work with batching mode for the create update and delete operations.
I have succeeded to do the creation operation with the following articles:
- https://vladmihalcea.com/postgresql-multi-row-insert-rewritebatchedinserts-property/
- https://www.baeldung.com/jpa-hibernate-batch-insert-update
At my application level, with the help of the proxy data source, I could see that the batching is working for all my operations, it looks like this:
[-exec-6] SLF4JQueryLoggingListener:20 - {"name":"Batch-Insert-Logger", "connection":33, "time":9, "success":true, "type":"Prepared", "batch":true, "querySize":1, "batchSize":5, "query":["
At the PostgreSQL level, I could see that the insertion works after I configured the reWriteBatchedInserts=true in my DB connection.
I verified it with the actual PostgreSQL logs.
However, for the update and delete operations, I can still see in the logs that it is not batched in the PostgreSQL level.
Is there any additional configuration that I need to do in order to get this done?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我们想要使用批处理进行插入/更新时,我们应该了解主键生成策略。如果我们的实体使用 GenerationType.IDENTITY 标识符生成器,Hibernate 将默默地禁用批量插入/更新。
请改用序列...
来源:Baeldung
When we want to use batching for inserts/updates, we should be aware of the primary key generation strategy. If our entities use GenerationType.IDENTITY identifier generator, Hibernate will silently disable batch inserts/updates.
Please use sequence instead...
Source: Baeldung