[英]jdbc executeBatch vs. execute with big query
I need to update / insert a large number of entries very fast. 我需要非常快速地更新/插入大量条目。 I see 2 options
我看到2个选项
The target db is oracle. 目标数据库是oracle。 The number of inserts/updates in a batch is a fixed number between 1000 and 10000 (does this number has some impact on performance?)
批处理中的插入/更新次数是1000到10000之间的固定数字(此数字会对性能产生影响吗?)
So what way to go? 那要走什么路呢?
Your options are essentially the same. 您的选择基本上是相同的。 In fact they may be identical, unless your second option is implemented in a poor way.
实际上,它们可能是相同的,除非您的第二种选择实施得不好。
Using built in PreparedStatement
batching is safer, since the driver will know what to do a lot better than you do. 使用内置的
PreparedStatement
批处理更为安全,因为驱动程序将比您更了解做什么。 There's less chances for programmer error, and should it ever happen that you change your database provider, you won't need to double check whether your solution is still valid. 程序员出错的机会更少,而且如果您更改数据库提供程序的情况发生过,则无需再次检查解决方案是否仍然有效。
Make sure to check out how to properly perform the batching. 确保检查出如何正确执行批处理。 For example the batch size is commonly
100
instead of the full amount of rows you wish to insert (so you would have 10 executeBatch()
es to insert your 1000 rows). 例如,批量大小通常为
100
而不是您希望插入的全部行数(因此,您将有10个executeBatch()
es来插入您的1000行)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.