by Razvan Popian
The result set fetch size is an important setting for processing result sets in a memory efficient way in JDBC. setFetchSize() method’s javadoc of java.sql.Statement class specifies the behavior of the fetch size:
“Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for ResultSet objects generated by this Statement. If the value specified is zero, then the hint is ignored. The default value is zero.”
PostgreSQL does not implement the above contract exactly as a value of 0 means to use the default fetch size configured in the driver properties (the name of the property is “defaultRowFetchSize”). Setting a non zero fetch size, works as one would expect for Statements and PreparedStatements, but unfortunately any fetch size set for CallableStatements is ignored. Moreover, the default value from the driver properties is used. By default, this is 0, whic...