Reputation: 9914
For bulk insertion we normally prefer BATCH operation. How exactly is it optimized for faster insertion in jdbc ?
Upvotes: 2
Views: 620
Reputation: 231851
Normally, by reducing network round-trips. If you are going to execute the same statement 100 times with 100 different sets of bind variables, for example, it would be much more efficient to send all 100 sets of bind variables to the database at once and get back all 100 results using a single network round-trip than it would to incur 100 separate network round-trips in order to execute each query sequentially. If you tell the JDBC driver that you want to create a batch, the driver can minimize the number of times it needs to communicate with the database.
Upvotes: 4