高效的多SQL插入 [英] Efficient Multiple SQL insertion

查看:185
本文介绍了高效的多SQL插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将1000行插入一个表(jdbc / connector-mysql数据库)的最佳/最有效时间是什么? (它是一个缓冲区,每次填满时都需要转储到数据库中)

What is the best/most time efficient way to insert 1000 rows into one table (jdbc/connector-mysql database)? (it is a buffer and need to be dumped into the database everytime it is full)

1-一个自动生成/同步的SQL语句?

1- One auto generated/concanated SQL statement?

2- for(int i = 0; i< 1000; i ++){con.prepareStatement(s.get(i)); } con.commit();

3-存储过程?

4 - 通过文件插入批量数据?

4- bulk data insertion via a file?

5-(您的解决方案)

5- (your solution)

推荐答案

LOAD DATA INFILE语句是可能是你表现最好的选择。 (上面的选项列表中的#4)虽然可能需要更多的代码来完成您的任务,因为您需要创建中间文件,然后将其发送到服务器,然后调用LOAD DATA将其放入数据库。

The LOAD DATA INFILE statement is probably your best bet for performance. (#4 from your list of options above) Though it will probably take more code to accomplish your task since you need to create the intermediate file, get it to the server and then call LOAD DATA to get it into your db.

MySql帮助页面引用:

MySql Help pages quote:


LOAD DATA INFILE语句读取
行从文本文件到
a的表格非常高速。

The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed.

这篇关于高效的多SQL插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆