I'm fetching data using CallableStatement with stored proc, ResultSet has 12000 rows and it is taking 30 seconds to process. I'd tried setting fetch size (rs.setFetchSize(500) but still, it is taking the same time to fetch whole data (30 sec).
callableStatement = conn.prepareCall(myProc);
callableStatement.setString("myParam", xyz);
callableStatement.registeroutputParameter("REVTAL", OracleTypes.CURSOR);
callableStatement .setFetchSize(1000); // I have tried with different values
rs = (ResultSet) callableStatement.getObject("REVTAL");
while(rs.next()) {`
myMethodToSetResultIntoList();
}
Is there any possible way other than fetch Size to optimize it?
I have tried this:
while(rs.next()) {`
logger(); // do nothing
}
It processed for 12000 rows in approx 3 seconds, so time is getting consumed in fetching the data from resultSet.
Also, It is confirmed that setfetchSize() is working properly as without setting fetch Size it is showing "fetchedRowCount" as 10 and with setFetchSize() as x, it is showing "fetchRowCount" as x on debug mode.
Actual while loop is like this:
while(rs.next()) {
Myclass mc = new Myclass();
mc.setA(rs.getString("parameterA");
mc.setB(String.valueOf(rs.getLong("parameterB");
//4 more string parameters same
mc.setG(myMethodToConvertDate(rs.getDate("Date");
myList.add(mc);
}
So it is taking approx 25 seconds to retrieve the data from resultSet and adding that to myList. There must be a solution for this.
Thanks in advance