Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Java application is taking long time compare than query browser to run the query.

stsivarajstsivaraj chennaiMember Posts: 1

Hi,
I am getting big time difference when I run same query in query browser and in my application. The query browser it took only 2 seconds to run the query. But in my application it is taking 20 seconds.
Actually, I am handling 12L records. I am using sql server database and used native SQL(JDBC) API in my application. I mean natve statement and resultSet API to fetch the record. I copied my code pieces here.

//------------------------ COUNT QUERY ------------------------------------
//It is taking 2 seconds in query browser but in my application takes 17 seconds
try{
String executeQry="select count(id) from temp where some condition";
statement = m_jdbcConnection
.prepareStatement(executeQry);
resultSet = statement.executeQuery();
while (resultSet.next()) {
totalCount = resultSet.getInt(1);
}
} catch(Exception e){
//
}

//------------------------ RESULTSET QUERY ------------------------------------
//It is taking 2 seconds in query browser but in my application takes 20 seconds
try{
String executeQry="select ID,NAME,... from temp where some condition";// I used rownumber to limit.
statement = m_jdbcConnection.prepareStatement(executeQry,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
resultSet = statement.executeQuery();
while (resultSet.next()) {
//PROCESS THE RESULTSET
}
} catch(Exception e){
//
}

Is there any mistake in my code to handle? or any logic I need to improve(Any Cache concept- Statement cache or ResultSet Cache).
Please suggest me what are items I need to be care while handling large data(Java Level)

Tagged:
Sign In or Register to comment.