开发者

Hibernate: Does a thread block while waiting for the database to insert a batch?

开发者 https://www.devze.com 2023-01-10 18:49 出处:网络
I\'m trying to find the optimal batch size for some operations we perform in bulk (persisting collections).If insert is going to block a thread, I think I\'m going to want to make the batch size ~ t开

I'm trying to find the optimal batch size for some operations we perform in bulk (persisting collections). If insert is going to block a thread, I think I'm going to want to make the batch size ~ t开发者_如何学运维he average size of the collection we are going to persist.

If that isn't the case, it might make more sense to find a smaller batch size to use.

Thanks in advance!


JDBC is synchronous which means that control will return to your code as soon as the operation is completed (either successfully or with an error).


Yes the thread is going to block. If you don't want your main thread to block, you can do the updates in a separate thread.

BTW, I can not see the relation of batch-size with thead-blocking issue. The thread is going to block no matter what batch size you use.

0

精彩评论

暂无评论...
验证码 换一张
取 消