简体   繁体   English

缓慢的MYSQL插入到数据库MyISAM

[英]Slow MYSQL Insert to DB MyISAM

I have a file (insert.sql) which has 250k rows like these with no key, no index : 我有一个文件(insert.sql),其中有25万行像这样,没有键,也没有索引:

INSERT `project_383`.`entity_metrics_build_1` VALUES ('d402afeb4630267f383b99875f37162d', 'ClMaxCycl', '-1');

INSERT `project_383`.`entity_metrics_build_1` VALUES ('d402afeb4630267f383b99875f37162d', 'ClLMethodsCalled', '0');

I input it to the my MyISAM table using mysql -u root -p project < insert.sql , the total time is 5 minutes. 我使用mysql -u root -p project < insert.sql将其输入到MyISAM表中,总时间为5分钟。

I see in another thread, people say they can insert millions of rows under 1 seconds. 我看到另一个话题,人们说他们可以在1秒内插入数百万行。 I really don't understand. 我真的不明白 Can somebody explain for me why my SQL is so slow ? 有人可以为我解释为什么我的SQL这么慢吗?

My Server is 16gb Cpu xeon. 我的服务器是16GB Cpu xeon。

Combine them into a single INSERT with multiple VALUES clauses: 将它们组合为具有多个VALUES子句的单个INSERT:

INSERT `project_383`.`entity_metrics_build_1`
VALUES ('d402afeb4630267f383b99875f37162d', 'ClMaxCycl', '-1'),
       ('d402afeb4630267f383b99875f37162d', 'ClLMethodsCalled', '0'),
       ...;

If you look at the file created by mysqldump , this is how it does it. 如果查看mysqldump创建的文件,这就是它的工作方式。

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

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