简体   繁体   English

JDBC中的批量插入

[英]Batch insertion in JDBC

For bulk insertion we normally prefer BATCH operation. 对于批量插入,我们通常更喜欢BATCH操作。 How exactly is it optimized for faster insertion in jdbc ? 如何精确优化以更快地插入jdbc?

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. 例如,如果要使用100个不同的绑定变量集执行同一条语句100次,则一次将所有100个绑定变量集发送到数据库并一次使用一次取回所有100个结果的效率会更高。网络往返,则要依次执行每个查询,就需要进行100次单独的网络往返。 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. 如果您告诉JDBC驱动程序要创建批处理,则该驱动程序可以最大程度地减少与数据库通信所需的次数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM