I have a file (insert.sql) which has 250k rows like these with no key, no index :
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.
I see in another thread, people say they can insert millions of rows under 1 seconds. I really don't understand. Can somebody explain for me why my SQL is so slow ?
My Server is 16gb Cpu xeon.
Combine them into a single INSERT with multiple VALUES clauses:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.