如何加速数据加载到InnoDB(LOAD DATA INFILE)?
我想加快数据加载速度。
我使用MySQL 5.5,InnoDB,有1M行数据(65Mb文件)。需要 5 分钟。
哪些 mysql 设置和命令会影响 InnoDB 的 LOAD DATA INFILE 速度?
谢谢。
I want to speed up a data loading.
I use MySQL 5.5, InnoDB and have 1M rows of data (65Mb file). It takes 5 minutes.
What mysql settings and commands affect the speed of LOAD DATA INFILE for InnoDB?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您因为要替换实时表的内容而很着急,那么可以这样做:
RENAME
是“瞬时”且原子的,因此您“永远”不会宕机,无论发生什么情况桌子尺寸。(因此您不必太担心
LOAD
的速度。)If you are in a hurry because you are replacing the contents of a live table, then do it this way instead:
The
RENAME
is 'instantaneous' and atomic, so you are 'never' down, regardless of table size.(Hence you don't need to worry so much about speeding up the
LOAD
.)我可以推荐这些设置来缩短加载时间:
除了设置之外,还有一些你可以做的事情自己做:
I can recommend these settings to improve load time:
Other than settings, there are some things you can do yourself:
尝试删除索引和触发器。您可以在加载后重新创建它们。还要考虑使用 my-huge.cnf 中的一些高负载设置而不是默认设置。
更多 innodb 性能设置:
http://www.mysqlperformanceblog。 com/2007/11/01/innodb-performance-optimization-basics/
Try removing indexes and triggers. You can re-create them after the load. Also look into using some of the high-load settings in my-huge.cnf instead of the defaults.
Some more innodb performance settings:
http://www.mysqlperformanceblog.com/2007/11/01/innodb-performance-optimization-basics/
这可能不完全是您正在寻找的东西,但这是我过去使用过的技巧
希望它有所帮助。
This might not be exactly what you're looking for but is a trick I've used in the past
Hope it helps.
如果可能的话,还要确保禁用二进制日志记录。
Also make sure that binary logging disabled if possible.