MySQL多次插入性能 [英] MySQL multiple insert performance

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

问题描述

我有大约3万条记录的数据.而且我需要将此数据插入到MySQL表中.我将这些数据按1000个数据包进行分组,并创建多个插入内容,如下所示:

I have data containing about 30 000 records. And I need to insert this data into MySQL table. I group this data in packages by 1000 and create multiple inserts like this:

INSERT INTO `table_name` VALUES (data1), (data2), ..., (data1000);

如何优化此插入的性能?每次可以插入1000条以上的记录吗?每行包含大小约为1KB的数据.谢谢.

How can I optimize performance of this inserting? Can I insert more than 1000 records per time? Each row contains data with size about 1KB. Thanks.

推荐答案

您需要检查mysql服务器配置,特别是检查缓冲区大小等.

You need to check mysql server configurations and specifically check buffer size etc.

您可以从表中删除索引(如果有的话),以使其更快.数据一旦进入,就创建索引.

You can remove indexes from the table, if any, to make it faster. Create the indexes onces data is in.

看这里,您应该得到所有需要的东西.

Look here, you should get all you need.

http://dev.mysql.com/doc/refman/5.0/en/insert-speed.html

它说一个具有多个值的插入语句比多个插入语句要快得多.

One insert statement with multiple values, it says, is much faster than multiple insert statements.

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

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