我使用mysql与hibernate和spring引导数据jpa (spring starter data -jpa和mysql-连接器-java)。最近,我将我的spring启动项目从1.5升级到2.0。用于保存可迭代的spring数据CrudRepository的API已经从saveAll()更改为saveAll()。我对代码进行了修改,它可以工作,但速度非常慢:
我已经用一个空表测试了两个弹簧版本的插入。mysql服务器版本没有改变:5.7.21-GPL( MySQL Community )
我需要每天插入200万个项目,这样的话,经济增长就会急剧放缓。这是我的配置:
spring.datasource.url = jdbc:mysql://localhost:3306/service?useSSL=false&rewriteBatchedStatements=true
spring.datasource.username = service
spring.datasource.password = service
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.hikari.maximum-pool-size=5
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.jdbc.batch_size=50
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true有没有人知道更新过程中发生了什么变化,以及如何再次加快更新速度?
发布于 2019-08-08 06:12:39
在spring.jpa.properties.hibernate.generate_statistics = application.properties集中
hibernate:
generate_statistics: truehttps://stackoverflow.com/questions/50044823
复制相似问题