mySQL

时间:2016-06-14 01:26:32

标签: mysql

每隔4个小时我们就会在一张大约100-150米的桌子中以1-15米的行装载csv。桌子每24小时修剪一次100米。每行少于100个字节。通常需要几分钟时间:

01:22:07 Keys for two_legs disabled. Affected rows: 0 [1 sec.]
01:22:07 Inserting new rows WITHOUT keyword CONCURRENT.
03:33:41 Data copied from /home/csv-tmp/new_two_legs_160613_010554.csv to two_legs. Affected rows: 10432731 [7894 sec.]
03:45:28 Keys for two_legs enabled. Affected rows: 0 [707 sec.]
03:45:28 INSERTED ROWS - 1774435 | REPLACED ROWS - 8658296.

几分钟后,我们在同一个表中插入更多行(现在更大):

04:04:07 Keys for two_legs disabled.
04:04:07 Inserting new rows WITHOUT keyword CONCURRENT.
04:05:57 Data copied from /home/csv-tmp/new_two_legs_160613_034534.csv to two_legs. Affected rows: 11363628 [110 sec.]
04:11:40 Keys for two_legs enabled. Affected rows: 0 [343 sec.]
04:11:40 INSERTED ROWS - 1887702 | REPLACED ROWS - 9475926.

使用的mysql QUERIES是:

ALTER TABLE $table DISABLE KEYS

LOAD DATA $c_piece LOCAL INFILE '$path' 
REPLACE INTO TABLE $table 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n' 
($fields)

ALTER TABLE $table ENABLE KEYS

我一直在努力解决这个问题,但无济于事。服务器本身没有任何延迟,例如高流量峰值;一切都发生在当地的夜晚,当客户不要求太多时。有时几天没有延迟,有时候每天都有。如何调试?

0 个答案:

没有答案