rewriteBatchedStatements参数

关于rewriteBatchedStatements这个参数介绍:

JDBC连接URL字符串中需要新增一个参数:rewriteBatchedStatements=true

url: jdbc:mysql://47.108.27.12:3308/lc_train?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true

  MySQL的JDBC连接的url中要加rewriteBatchedStatements参数,并保证5.1.13以上版本的驱动,才能实现高性能的批量插入。
MySQL JDBC驱动在默认情况下会无视executeBatch()语句,把我们期望批量执行的一组sql语句拆散,一条一条地发给MySQL数据库,批量插入实际上是单条插入,直接造成较低的性能。
只有把rewriteBatchedStatements参数置为true, 驱动才会帮你批量执行SQL
另外这个选项对INSERT/UPDATE/DELETE都有效

随笔看心情
原文地址:https://www.cnblogs.com/stromgao/p/15208902.html