Wednesday, December 22, 2010

How does batch update improve performance vs multiple updates?

When I had technical discussion with my friend, he was asking me the question "How does batch update improve performance?". I spent sometime to find out an answer for this question. Hope this will find useful for others. My friend thinks that batch update will update database in asynchronously, means java will hand over the control to Oracle to execute the update statement and just get back control to process next set of data. Meanwhile Oracle will process those update statements. His assumption is wrong. When we do multiple updates using for loop in java, there is context switching happens between Java & Oracle to execute each update statement. But, when we do batch update in Java environment we collect all update statements & switch to oracle to execute all statements at once. When we avoid this context switching, we gain more performance.

No comments:

Post a Comment

Followers