I am using JDBC to fetch data(Oracle Database) using Select Query in object accountdetailsList.I did read many post regarding performance issues with Result Set.Currently I am getting maximum 1000 Records in Development Environment so retrival is fast and I am not facing any performance issues.So to improve performance in PRODUCTION where there would be millions of Records I am using setFetchSize().As I am new to JDBC,I am looking for some expert suggestions if this is the correct way of handling large data.
AccountDetailsList accountdetailsList = new AccountDetailsList();
List<AccountDetails> accountDetails = new ArrayList();
try {
String sql_qry = "SELECT a.BILLING_ACCOUNT_ID,a.VALID_TO,a.STATUS_TYPE_KEY from tablename a where a.STATUS_TYPE_KEY='CLOSED' "
+ "and a.VALID_FROM >'"
+ formatStartDate+ "' and a.VALID_TO >'"+ formatToDate+ "'";
this.preparedStatement = dbconnection.prepareStatement(sql_qry);
preparedStatement.setFetchSize(100);
ResultSet rs = this.preparedStatement.executeQuery();
while (rs.next()) {
AccountDetails detailsVo = new AccountDetails();
detailsVo.setBillingAccountId(rs.getString("BILLING_ACCOUNT_ID"));
detailsVo.setValidto(rs.getDate("VALID_TO"));
detailsVo.setStatus(rs.getString("STATUS_TYPE_KEY"));
accountDetails.add(detailsVo);
}
accountdetailsList.setAccountdetailsList(accountDetails);
So Is there any other way to improve performance.setFetchSize(100) is ok or setFetchSize(1000) can also be used? Thanks