Results 1 to 2 of 2
  1. #1
    stsivaraj is offline Member
    Join Date
    Nov 2010
    Posts
    22
    Rep Power
    0

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

    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,Resul tSet.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)
    Last edited by stsivaraj; 03-17-2016 at 04:48 PM. Reason: format

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

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

    What exactly are you timing?
    If you're timing the whole row processing then that's is not timing like with like.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 0
    Last Post: 12-30-2014, 01:59 PM
  2. Replies: 3
    Last Post: 10-19-2012, 10:16 PM
  3. Query taking lot of time to execute..
    By asgardar in forum Advanced Java
    Replies: 4
    Last Post: 01-19-2011, 07:09 PM
  4. MySQl query taking too much time
    By jessie in forum JDBC
    Replies: 16
    Last Post: 11-11-2010, 01:09 PM
  5. Query regarding cancelling long run jobs
    By joydev in forum Threads and Synchronization
    Replies: 3
    Last Post: 07-03-2009, 04:19 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •