Hibernate multi row insert postgresql

2019-08-10 12:26发布

问题:

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.

回答1:

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.