简体   繁体   English

改善mysql加载数据

[英]improve mysql load data

Is there any mysql parameter to improve the speed of "LOAD DATA INFILE " ? 是否有任何mysql参数来提高“LOAD DATA INFILE”的速度?

I am using 1 MyISAM and 1 TokuDB table. 我正在使用1个MyISAM和1个TokuDB表。 The data is saved as Tab separated text file. 数据保存为制表符分隔的文本文件。

There are a number of ways to speed this up. 有很多方法可以加快速度。 http://dev.mysql.com/doc/refman/5.1/en/insert-speed.html http://dev.mysql.com/doc/refman/5.1/en/insert-speed.html

For large inserts it's usually the index updating that slows things down. 对于大型插入,通常是索引更新会降低速度。 So even using techniques like locking the table, turning off index updates, it can still take a long time when the indexes have to be created. 因此,即使使用锁定表,关闭索引更新等技术,仍然需要很长时间才能创建索引。 Index creation, and thus inserts, on MyISAM tables can be sped up by increasing the value of the key_buffer_size. 可以通过增加key_buffer_size的值来加速MyISAM表上的索引创建和插入。 Make this large enough to hold the index(es) and your inserts can speed up by orders of magnitude. 使其足够大以容纳索引,并且您的插入物可以加速数量级。 You can reduce it after the insert if need be. 如果需要,您可以在插入后减少它。

Are you loading into an empty table or a table with rows already in it? 您是否已加载到空表或已包含行的表中? If the table is empty, TokuDB will implement it's bulk loader and load the data very quickly. 如果表是空的,TokuDB将实现它的批量加载器并非常快速地加载数据。

Also, if you are loading data into a table with unique indexes (PK or secondary), turn off unique_checks if you know the data is unique. 此外,如果要将数据加载到具有唯一索引(PK或辅助索引)的表中,请在知道数据唯一的情况下关闭unique_checks。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM