Java has the PreparedStatement addBatch + executeBatch to do multiple insertions efficiently.
What is the fasted way to do a batch of inserts using php\'s mysqli extensi
MySQL natively supports multiple insertions with one query.
INSERT INTO [Table] ([Column List])
VALUES ([Value List 1])
, ([Value List 2])
[...]
, ([Value List N])
I realize this question is old, but for anyone else that comes across this, I found some useful information on this topic here: insert multiple rows via a php array into mysql.
Depending on your needs, it may be fastest to pipe the data as csv directly into LOAD DATA INFILE. However, be very cautious with this approach as it offers no protection against injection attacks.
I have used this approach in the past, validating the data cleanliness during csv generation.