Friday, June 11, 2010

Result Set Fetch Size

setFetchSize() in resultSet and Statement.
Both ResultSet and Statement have the SetFetchSize method. When used in the Statement all of the ResultSets returned by that Statement will have the same fetch size.
SetFetchSize determines the amount of data blocks or rows that should be carried to the client from the server after executing a statement.

Advantanges of using setFetchSize().
I did a comparitive study aout the impact of setting the fetch size when executing a query that resulted in about 1k records.
DB: Oracle 10g
Driver: oracle thin
Java version: 5
The database server was not in the local network.
FetchSize Time in entire processing:
Default:031897ms
1031476ms
1006858ms
5005514ms

The advantage is self evident.

No comments: