#include #include "AccumulateInsert.h" AccumulateInsert::AccumulateInsert(std::string const &common) : _common(common + " VALUES ") { } void AccumulateInsert::add(std::string const &toInsert) { if (_accumulated.empty()) _accumulated = _common; else _accumulated += ','; _accumulated += toInsert; } std::string AccumulateInsert::get() { assert(!empty()); std::string result = _accumulated; _accumulated.clear(); return result; } /* I used the following notes in my performance testing: mysqldump --no-create-info --skip-extended-insert --skip-add-locks --skip-add-drop-table -u root -p -h dom --where="end_time > '2006-08-01' and symbol like 'A%'" mydb candles_5m > candles_a.sql mysqldump --no-create-info --skip-add-locks --skip-add-drop-table -u root -p -h dom --where="end_time > '2006-08-01' and symbol like 'A%'" mydb candles_5m > candles_b.sql date +%s.%N;mysql -u root -p -h dom mydb < candles_r.sql;date +%s.%N [phil@guru /tmp]$ date +%s.%N ; mysql -u root -pxxx123 -h dom mydb < candles_r.sql ; date +%s.%N 1154748723.555193000 1154749744.198615000 [phil@guru /tmp]$ (echo 'begin;';cat candles_r.sql ; echo 'commit;') > candles_rt.sql 1020.643422 seconds, 17 minutes and 0.6 seconds all defaults innodb_log_buffer_size = 8M, innodb_buffer_pool_size = 14G 1034.184375 seconds innodb_log_buffer_size = 32M 1013.893772 seconds innodb_buffer_pool_size = 2G 1013.045068 seconds put it all into a transaction. 32.054542 seconds insert ignore. 6.178972 seconds replace with extended insert syntax 3.430884 seconds insert ignore with extended insert syntax 899.614726 seconds, 15 minutes put it all between lock and unlock After running these tests I changed the BIOS settings on the RAID card on a slow server. I switched from write-through to write-back, allowing the controler to do more with its cache. That made the writes over 100 times as fast when we did them one at a time. I haven't tried the combined query to see how much faster it is. */