Hibernate多行插入postgresql [英] Hibernate multi row insert postgresql
问题描述
现在我已经使用hibernate(hibernate.jdbc.batch_size = 50) 但是在db日志中仍然有单个插入 这实际上与Hibernate无关,插入操作由JDBC驱动程序处理。 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. 这篇关于Hibernate多行插入postgresql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
进行批量插入,但据我所知
I知道我可以告诉我的数据库驱动程序为每批插入操作创建多行插入,以加速使用rewriteBatchedStatements的性能:
jdbc:postgresql:// localhost:5432 / mydb?rewriteBatchedStatements = true
我在做什么错误?谢谢。
rewriteBatchedStatements
是一个MySQL特定的参数,所以它不适用于PostgreSQL数据库。如果你真的需要使用PostgreSQL进行批量插入,一个href =https://stackoverflow.com/a/12207237/1743880>这个其他答案,它解释了如何做到这一点。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.