Optimization for Lightning-Fast Data Import with MySQL
Query:
When importing voluminous data (approximately 3.6 million rows) into a MySQL InnoDB table using "Load data infile", how can the process be accelerated? Additionally, how can a slow query be terminated without interrupting the MySQL service?
Solution:
Data Import Acceleration:
To optimize the data import process while utilizing Innodb:
truncate <table>; set autocommit = 0; load data infile <path> into table <table>... commit;
set unique_checks = 0; set foreign_key_checks = 0; set sql_log_bin=0;
Slow Query Termination:
To terminate a slow query without restarting MySQL:
SHOW PROCESSLIST;
KILL <thread_ID>;
Performance Statistics:
Based on observed bulk load performance:
The above is the detailed content of How to Speed Up Data Import into MySQL InnoDB and Terminate Slow Queries?. For more information, please follow other related articles on the PHP Chinese website!