What is the quickest way to do mass inserts via JDBC
JDBC and MySQL 5.0.X (.15)
I did some tests with inserting large amounts of data into MySQL 5.0.15, to see what the fastest way was and to insert via JDBC.
I used the a table format, which has about 16 rows in it and I inserted into an empty table 100,000 of the same rows. There were no indexes and no keys on the table.
Three scenarios.
1. 100,000 different inserts each. With one commit at the end. Took 1917 seconds.
2. 100,000 rows inserted with a statement in 1000 batches of 100. Took 35 seconds.
3. 100,000 rows inserted with a preparedstatement in 1000 batches of
This of course has no business logic and no string handling implications as I’m
MySQL can handle and its pretty interesting that it handles things at
1. network I/O
2. disk I/O
3. DB server CPU cycles are way down on this list being relatively
cheap.
