Batch Limit

Hi,

I have to perform multiple updates on a table based on ids. To avoid multiple DB hits, I am using PreparedStatement's Batch. I wanted to know the number of statements that can be added to the batch without performance hit or any other issue. I am talking about 1000, 5000, 10000 or more.

Thanks in advance.

[330 byte] By [mod_pa] at [2007-11-27 8:22:44]
# 1
It depends.If performance is your overriding concern then you should look to use whatever specific batch tools are available for your database.
cotton.ma at 2007-7-12 20:11:27 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Without any batch tool can I have 20,000 records added to the PreparedStatement batch?
mod_pa at 2007-7-12 20:11:27 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
> Without any batch tool can I have 20,000 records> added to the PreparedStatement batch?It depends.
cotton.ma at 2007-7-12 20:11:27 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

> I wanted to know the

> number of statements that can be added to the batch

> without performance hit or any other issue.

"Without ANY performance hit or ANY other issue"? Then the answer is somewhere around 1, otherwise you risk grabbing more resources then you would without using batch which could in theory destabilize your application and/or change the performance characteristics of your application.

On my production system, I found that 3,000 provided better performance then less then 3,000 and better stability then more then 3,000. It was the balancing point on my system, but your DBMS could be setup quite differently, and your SQL could use different resources. Therefore that value has very little meaning to anyone other then me.

Because "it depends" you need to try it on your system and see what value works best for you.

Best of luck.

WorkForFooda at 2007-7-12 20:11:27 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
I too had thought to do a check for the limit on the actual system. I wanted to know that if it is done this way or there is some limit.Thanks for the answer.
mod_pa at 2007-7-12 20:11:27 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...