当前使用版本(必填,否则不予处理)

mybatis-plus 3.4.2版本

该问题是如何引起的?(确定最新版也有问题再提!!!)

批量插入50000条数据,使用jdbc批量插入平均时间为9s,使用mybatis-plus的saveBase时间是176s,差距还是挺大的。 并且我的jdbc连接中,使用了rewriteBatchedStatements=true

重现步骤(如果有就写完整)

多次运行,时间较稳定。

报错信息

Comment From: lltx

mysql 选装一下一下这个插件 https://mp.baomidou.com/guide/crud-interface.html#insertbatchsomecolumn

其他数据库 自己拼sql

mybatis-plus 为了多数据源兼容性 是for loop insert

Comment From: cyxinda

谢谢,问题已经解决。

Comment From: smartlin

谢谢,问题已经解决。 为什么选装了插件 比仅仅设置了rewriteBatchedStatements=true要慢了?不知道你的咋样 仅仅设置了rewriteBatchedStatements=true 插入10W条数据 1972ms 设置了rewriteBatchedStatements=true 和选装了插件 时间 4480ms

Comment From: cyxinda

我当时仅仅使用rewriteBatchedStatements=true不好使,调用mybatis plus原生的saveOrUpdate方法,并没有按照预想执行批量插入。使用这个插件好使,这个插件使用的是foreach组装batch的SQL。至于为什么慢了,说不好原因。可能是mysql执行引擎的问题?

发自我的iPhone

在 2021年4月21日,16:17,smartlin @.***> 写道:

 谢谢,问题已经解决。 为什么选装了插件 比仅仅设置了rewriteBatchedStatements=true要慢了?不知道你的咋样 仅仅设置了rewriteBatchedStatements=true 插入10W条数据 1972ms 设置了rewriteBatchedStatements=true 和选装了插件 时间 4480ms

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.