使用 LOAD DATA INFILE 插入到 innodb 的 2M 行需要 7.5 分钟,分析显示 99% 的时间在“系统锁定”中。
这能告诉我什么有用吗?
mysql> set profiling=1;
Query OK, 0 rows affected (0.00 sec)
mysql> LOAD DATA CONCURRENT LOCAL INFILE '/tmp/item' REPLACE INTO TABLE item_load;
Query OK, 1964807 rows affected, 8 warnings (7 min 27.35 sec)
Records: 1964806 Deleted: 1 Skipped: 0 Warnings: 8
mysql> show profile for query 1;
+------------------------------+------------+
| Status | Duration |
+------------------------------+------------+
| starting | 0.000206 |
| checking permissions | 0.000015 | …Run Code Online (Sandbox Code Playgroud) 我正在尝试将数据以 CSV 文件形式加载到 mysql 数据库中。我发现我们可以使用 LOAD DATA INFILE 命令来做到这一点。但根据 mysql 文档,它不是复制安全的。(见这里)
有没有比通过应用程序更好的方法来做到这一点?