7

I'm trying to optimize the process of inserting a large number of results to a remote mySQL database. I'm using simple jdbc for that.

Currently I'm replacing exiting statements with PreparedStatement and execute methods with addBatch/executeBatch methods. Does anyone know which are the limits of a batch execution? How many batches can I add before execution to make sure the process doesn't fail? The queries are not special queries, they don't have blobs or other large fields.

adiian
  • 1,382
  • 2
  • 15
  • 32

1 Answers1

5

@BalusC hit the nail on the head. If you're using MySQL, use the latest driver add rewriteBatchedStatements=true to your connection string to make statement.addBatch() actually create batch inserts.

Nice presentation on MySQL JDBC performance: http://assets.en.oreilly.com/1/event/21/Connector_J%20Performance%20Gems%20Presentation.pdf

Community
  • 1
  • 1
Joshua Martell
  • 7,074
  • 2
  • 30
  • 37