科技公司 网站 石家庄,dw php网站开发书籍云盘,郑州做网站推广的公司哪家好,app开发设计最近负责的项目需要数据同步入库MySQL#xff0c;为了测速那种入库方式效率比较高#xff0c;为此进行了以下的对比实验#xff0c;在此记录一下
实验表单数据格式 实验代码
共三种方法对比
mutiSqlInsert:
一条一条插入#xff0c;最后一次提交 singleSqlInsert…最近负责的项目需要数据同步入库MySQL为了测速那种入库方式效率比较高为此进行了以下的对比实验在此记录一下
实验表单数据格式 实验代码
共三种方法对比
mutiSqlInsert:
一条一条插入最后一次提交 singleSqlInsert
用for循环拼接好插入sql一次执行 executeBatchInsert
使用MySQL提供的方法executeBatch()同样使用一次提交
实验结果
1W条数据插入
mutiSqlInsert
singleSqlInsert
executeBatchInsert 10W条数据插入
mutiSqlInsert
singleSqlInsert
executeBatchInsert
2000条数据插入(当前kafka设置的单次最大拉取数为2000)
Kafka配置截图
mutiSqlInsert
singleSqlInsert
executeBatchInsert 结论 在一次性拉取数据较少时mutiSqlInsert和executeBatchInsert的性能相差不大 当一次性插入数据非常多时比如10W条singleSqlInsert的性能会急剧下降甚至不如mutiSqlInsert 关于10W条数据插入时singleSqlInsert的性能会急剧下降的原因参考此文 https://blog.csdn.net/Tom_sensen/article/details/127922964