Performance Issue using SQLJ

Ask a Question related to IBM DB2, Design and Development.

  1. #1

    Default Performance Issue using SQLJ

    Hi. We're looking at using SQLJ to see how we could incorporate it
    into our environment and achieve better throughput and cost savings
    over using dynamic SQL through JDBC. We currently run DB2 v7.1 for
    os/390 and on the client side DB2 NT v7 FP7.

    SQLJ was easy enough to run, but then I ran some benchmark tests
    between SQLJ and JDBC so we could give some meaningful statistics
    about expected savings to management. In the benchmark tests I found
    that the Dynamic JDBC SQL was outperforming the SQLJ. The results I
    got follow (for retrieving 1 row - multiple times):

    Times are in seconds

    Tries 1 10 50 100 500 1000
    SQLJ 0.231 0.580 2.223 4.186 20.360 42.441
    JDBC 0.029 0.259 1.311 2.684 13.829 28.821

    When I watched through activity monitor I saw that the problem was
    SQLJ set up a cursor for processing my single-row select statement.
    So it was incurring cursor for each time it was executed.

    I also, however, ran a benchmark test on updating the same row 20
    times. Again SQLJ was about twice as slow as Dynamic SQL.

    So, I have a couple of questions.

    1) Is it possible to get SQLJ to perform a non-cursored select? I've
    not been able to find a way (looking at the sample programs and
    documentation and news groups).

    2) Is there anything else I'm doing wrong? I basically just used the
    static.sqlj sample program and changed values to execute in our
    environment, then pre-compiled it, then compiled the output java pgm.

    Here are the sections of code I used for benchmarking -
    For SQLJ -
    #sql { SELECT field1 INTO :field1_var FROM dbname.tablename WHERE
    row_id = 1 } ;

    For JDBC -
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("Select field1 from
    dbname.tablename where row_id = 1");

    while (rs.next())
    {
    String a = rs.getString(1);

    System.out.print(" business name= " + a);
    System.out.print("\n");
    }

    rs.close();
    stmt.close();

    Thanks for any suggestions,
    klh
    klh Guest

  2. Similar Questions and Discussions

    1. Performance issue : local vs remote
      Hi, I have 2 installation of CF MX 7 : 1 on my desktop, and one on a powerful Windows server. I'm experiencing poor performance when opening a...
    2. Performance issue
      I have an array with around 40 different url values in it. Im trying to cfhttp each URL in turn, and then parse the contents of each URL one by one....
    3. IsInRole Performance Issue
      Hi, We have a very large AD here and I am noticing that the WindowsPrinciple IsInRole function is taking upwards of 1 second to respond with just a...
    4. CFMail - performance issue
      Hi, I have developed a discussion board on which users can subscribe to particular topics. Subscribed users receive an email (with link back to...
    5. 7.x to 9.x Performance issue in the extreme
      Greetings, The problem: I run an identical program on Server A and Server B. On Server A the program runs in 12 seconds. On Server B it takes 1.5...
  3. #2

    Default Re: Performance Issue using SQLJ

    klh <klharwell@kcc.usda.gov> wrote:
    > Hi. We're looking at using SQLJ to see how we could incorporate it
    > into our environment and achieve better throughput and cost savings
    > over using dynamic SQL through JDBC. We currently run DB2 v7.1 for
    > os/390 and on the client side DB2 NT v7 FP7.
    >
    > SQLJ was easy enough to run, but then I ran some benchmark tests
    > between SQLJ and JDBC so we could give some meaningful statistics
    > about expected savings to management. In the benchmark tests I found
    > that the Dynamic JDBC SQL was outperforming the SQLJ. The results I
    > got follow (for retrieving 1 row - multiple times):
    >
    > Times are in seconds
    >
    > Tries 1 10 50 100 500 1000
    > SQLJ 0.231 0.580 2.223 4.186 20.360 42.441
    > JDBC 0.029 0.259 1.311 2.684 13.829 28.821
    >
    > When I watched through activity monitor I saw that the problem was
    > SQLJ set up a cursor for processing my single-row select statement.
    > So it was incurring cursor for each time it was executed.
    >
    > I also, however, ran a benchmark test on updating the same row 20
    > times. Again SQLJ was about twice as slow as Dynamic SQL.
    >
    > So, I have a couple of questions.
    >
    > 1) Is it possible to get SQLJ to perform a non-cursored select? I've
    > not been able to find a way (looking at the sample programs and
    > documentation and news groups).
    Did you run "db2sqljcustomize" to generate precompiled packages and bind
    them to the database you are using?

    --
    Knut Stolze
    Information Integration
    IBM Germany / University of Jena
    Knut Stolze Guest

  4. #3

    Default Re: Performance Issue using SQLJ

    > Did you run "db2sqljcustomize" to generate precompiled packages and bind
    > them to the database you are using?
    No. I followed the sample from the documentation.
    1 - Turned off java compiler "SET JAVA_COMPILER=NONE".
    2 - Ran the bldsqlj.bat (as "bdlsqlj TestSQLJ dbname userid pswd")
    which created the TestSQLJ.java, TestSQLJ_SJProfile0.ser, and
    TestSQLJ_SJProfileKeys.class files, as well as created a package for
    the program.
    3 - Compiled the java program "javac TestSQLJ.java"
    4 - Executed the program.

    I didn't see anything about db2sqljcustomize. It's not in my
    documentation, nor can I find it in any of my installation
    directories.

    Thanks,
    klh
    klh Guest

  5. #4

    Default Re: Performance Issue using SQLJ

    > Have a look here:
    > [url]http://www7b.boulder.ibm.com/webapp/dd/ViewServlet.wss?viewType=Library&devDomain=dmdd&so rtBy=Posted&start=1&keyword=&prodfam=0&topic=0&for mat=18&count=0[/url]
    >
    > and search for "SQLJ". There is a tutorial that talks about performance for
    > SQLJ and JDBC which might help you along.
    Thanks for the tip, Knut. Ultimately, though, none of the suggestions
    helped.

    I guess I'll have to accept that SQLJ runs slower in our environment
    (at least in version 7.1). However, I still have the question about
    the "Select Into" statement. All of the IBM documentation says "The
    SELECT INTO statement produces a result table that contains at most
    one row". So why would the SQLJ translator turn that into a cursored
    select? Since it does create a cursor it invokes all the overhead of
    describing, opening, and fetching.

    Thanks,
    klh
    klh Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139