JDBC rewriteBatchedStatements对批量插入的影响
来源:互联网 发布:17年淘宝生意越来越差 编辑:程序博客网 时间:2024/04/20 06:01
JDBC rewriteBatchedStatements对批量插入的影响
如果不开启rewriteBatchedStatements=true,那么jdbc会把批量插入当做一行行的单条处理,也即没有达到批量插入的效果
示例代码
表结构CREATE TABLE `batch_insert_test_db` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
代码connection.setAutoCommit(false);pstm = connection.prepareStatement("insert into batch_insert_test_db(name)values(?)");for (int i = 0; i < 10; i++) { pstm.setString(1, "name#" + System.currentTimeMillis()); pstm.addBatch();}pstm.executeBatch();connection.commit();
在rewriteBatchedStatements=false
的情况下,上面的代码会发送10次insert命令
tcpdump抓包如下:
在rewriteBatchedStatements=true
的情况下,只会发送一次insert命令
tcpdump抓包如下:
源码分析:
PreparedStatement.java#1451
还有一个注意事项,如果不是insert语句,是batchDelete()或者batchUpdate(),在batchSize <= 3的情况下,jdbc选择一条一条执行,而不是批量。
0 0
- JDBC rewriteBatchedStatements对批量插入的影响
- MySQL Jdbc驱动的rewriteBatchedStatements参数--批量修改开关
- mysql批量插入更新加参数rewriteBatchedStatements
- JDBC的批量批量插入
- JDBC的批量批量插入
- JDBC的批量插入
- JDBC的批量插入
- MySQL Jdbc驱动的rewriteBatchedStatements参数
- 介绍MySQL Jdbc驱动的rewriteBatchedStatements参数
- 介绍MySQL Jdbc驱动的rewriteBatchedStatements参数
- JDBC的批量插入操作
- MySql 的批量操作,要加rewriteBatchedStatements参数
- MySql 的批量操作,要加rewriteBatchedStatements参数
- MySql 的批量操作,要加rewriteBatchedStatements参数
- MySql 的批量操作,要加rewriteBatchedStatements参数
- MySql 的批量操作,要加rewriteBatchedStatements参数
- MySql 的批量操作,要加rewriteBatchedStatements参数
- JDBC批量插入数据的性能测试
- 网关、子网掩码、DNS各有什么作用
- UIImageView
- Android之异步任务AsyncTask解析XML数据
- iOS ---清除缓存
- 【探索】NodeJS中间层搭建——楔子
- JDBC rewriteBatchedStatements对批量插入的影响
- Android线程池使用终结版
- QQ临时回话代码
- 第一章 Linux历史和标准
- html之object标签的classid收集
- HDU 5597 GTW likes function
- redis-3.0.5安装
- fuseTools 入门开发工具配置
- 启动自己另一个程序的activity