Hibernate多行插入postgresql [英] Hibernate multi row insert postgresql

查看:353
本文介绍了Hibernate多行插入postgresql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我已经使用hibernate(hibernate.jdbc.batch_size = 50)
进行批量插入,但据我所知 hibernate会批量生成单个插入
I知道我可以告诉我的数据库驱动程序为每批插入操作创建多行插入,以加速使用rewriteBatchedStatements的性能:
jdbc:postgresql:// localhost:5432 / mydb?rewriteBatchedStatements = true

但是在db日志中仍然有单个插入
我在做什么错误?谢谢。

解决方案

这实际上与Hibernate无关,插入操作由JDBC驱动程序处理。



rewriteBatchedStatements 是一个MySQL特定的参数,所以它不适用于PostgreSQL数据库。如果你真的需要使用PostgreSQL进行批量插入,一个href =https://stackoverflow.com/a/12207237/1743880>这个其他答案,它解释了如何做到这一点。


Now I have working batch inserts with hibernate ("hibernate.jdbc.batch_size = 50) but as far as i know hibernate generates single inserts in batches. I know that I can tell my db driver to create multi-row insert for every batch of inserts to speed up performance using rewriteBatchedStatements: jdbc:postgresql://localhost:5432/mydb?rewriteBatchedStatements=true

But in db logs there are still single inserts. What am I doing wrong? Thanks.

解决方案

This actually has nothing to do with Hibernate. The inserts are handled by the JDBC driver.

rewriteBatchedStatements is a MySQL specific parameter so it won't work with a PostgreSQL database. If you really need to do bulk inserts with PostgreSQL, take a look at this other answer which explains how to do it.

这篇关于Hibernate多行插入postgresql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆