The current method is:
function tableInsertBatch($tableName, $fields, $values);
Question(s):
ALTER TABLE $tableName DISABLE KEYS;
LOAD DATA INFILE $path REPLACE INTO $tableName ...etc...;
ALTER TABLE $tableName ENABLE KEYS;
ALTER TABLE $tableName DISABLE KEYS;
Not necessary, Mysql will automatically disable keys before and build the index once all have been inserted.
I also think the code could be improved, however to really do it properly we need to understand where the memory grows and how it will minimize it. I propose we postpone this work until later on where a script will help us assess the memory limitations of Archiving (kind of #766 )
see this FAQ load data in file piwik