views:

38

answers:

2

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 ~ the 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!

A: 

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).

Aaron Digulla
A: 

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.

Tahir Akhtar