JDBC batch insert performance

Posted by wo_shi_ni_ba_ba on Stack Overflow See other posts from Stack Overflow or by wo_shi_ni_ba_ba
Published on 2010-06-07T21:17:47Z Indexed on 2010/06/07 21:22 UTC
Read the original article Hit count: 203

Filed under:
|
|
|

I need to insert a couple hundreds of millions of records into the mysql db. I'm batch inserting it 1 million at a time. Please see my code below. It seems to be slow. Is there any way to optimize it?

try { // Disable auto-commit connection.setAutoCommit(false); // Create a prepared statement String sql = "INSERT INTO mytable (xxx), VALUES(?)"; PreparedStatement pstmt = connection.prepareStatement(sql); Object[] vals=set.toArray(); for (int i=0; i

© Stack Overflow or respective owner

Related posts about mysql

Related posts about Performance