Steve
Steve

Reputation: 4691

Performance between SimpleJdbcInsert and PreparedStatement?

I have a process that is reading a large dataset and then inserting it into a database. I'm debating between SimpleJdbcInsert and plain old PreparedStatements.

While the former certainly seems easier....is it slower in a significant way? I was wondering if anyone had seen/done a performance comparison.

Upvotes: 0

Views: 677

Answers (1)

GreyBeardedGeek
GreyBeardedGeek

Reputation: 30088

Performance for this type of operation is dependent on whether you're doing single inserts or batch inserts, and for large numbers of inserts, the difference can be quite significant.

Batch inserts send a group of inserts to the database at once, so are more efficient than sending one at a time.

You can do batch inserts either way- SimpleJdbcInsert has an executeBatch() method, while PreparedStatement uses addBatch()/executeBatch().

Upvotes: 1

Related Questions