今天有個批量生成合同編號的操作,我插入了10000條數據,用時446s,這顯然合不合理,也考慮過多線程,但是放棄了
只需在mysql鏈接中加入如下配置
配置:rewriteBatchedStatements=true
完整鏈接:
jdbc:p6spy:mysql://xxx.xx.xxx.xxx:3306/gym_ok_sjyf?serverTimezone=Hongkong&characterEncoding=utf-8&allowMultiQueries=true&rewriteBatchedStatements=true
我使用了p6spy,注意下沒使用就是用原有的鏈接,可以看到截圖實測插入2s,在相同數據下提高了223倍