Friday, October 14, 2011

Performance in JDBC

http://www.precisejava.com/javaperf/j2ee/JDBC.htm#JDBC110

I found this very useful link on net.
I wrote a program to grab 5million rows of data from DB and to store it on my harddrive.
It took almost 12 hours

I used the following function from ResultSet to improve the performance.
resultSet.setFetchSize(2000);

By default the FetchSize is 10 rows, By varying size you see the performance change.

Below are the statistics for pulling 100000 rows
setFetchSize      Minutes
10                      12
2000                  4.5
20000                2.6
100000              java.lang.OutOfMemoryError: requested array is larger than heap