3
votes

Recently we change our connection pool to migrate for Oracle UCP. Before the migration, we used the pool embeded with the oracle jdbc driver (ojdbc6.jar).

Our problem is the elapsed time during the phase of the bind variables. With UCP, the time to bind a variable is greater than the old pool because it use introspection.

In a normal case (select or update), the time to bind the variables is very small compare to the time of the execution of the sql query. But, when we used a PreparedStatement for a batch execution, we do a lot of binding variables and sometimes we run the query by calling pst.excuteBatch().

As an example, this is a small program to illustrate the elasped time with the two pools.

PreparedStatement ppst = connection.prepareStatement(INSERT_SQL);

...

private long setParam(PreparedStatement prepStmt) throws SQLException {
    long d = 0;
    for (long i = 1; i <= 750 000; i++) {
        int index = 1;
        prepStmt.setString(index++, "1470");
        prepStmt.setTimestamp(index++, new Timestamp(System.currentTimeMillis()));
        prepStmt.setInt(index++, 1);
        prepStmt.setObject(index++, String.valueOf(i));
        prepStmt.addBatch();
    }
    prepStmt.clearBatch();
    return d;
}

With the old pool embeded with the ojdbc6 driver, elapsed time is : 7.653 sec.
With the UCP pool, elapsed time is : 10.92 sec.

In this example we have 750 000 iterations with 4 bind variables. In our production batch, we have 50 000 000 iterations. So the elapsed time to bind variables is long and our batch time has grow up.

Technical Informations :
Old pool : ojdbc6.jar (11.2.0.3.0)
New Pool : ojdbc6.jar (11.2.0.3.0) + ucp.jar (11.2.0.4.0)

We have profiled the binding variable phase :

  • With the new pool UCP, each variable is binded with java relection api which is slower.
  • With the old pool, each variable is binded directly with the corresponding method of the variable type.

How can we improve the performance of the binding variable for the UCP pool ? Do you know a way to disable the usage of java reflection api ?

1
Have you tried enabling implicit statement caching as explained here?Mick Mnemonic
The proxy mechanism in UCP has been improved in the 12.2.0.1. You will need to upgrade both ucp and jdbc (both have to be on the same version).Jean de Lavarene
Thanks for the suggestion to ugrade to the last UCP and Jdbc driver version. The elapsed time look fine with the 12.2.0.1. Batch time with old pool : 549 s Batch time with UCP pool 11.2.0.4.0 : 1007 sec. Batch time with UCP pool + Jdbc driver v.12.2.0.1.0 : 585 sec. This time is now acceptable for me.R Thevenoux

1 Answers

0
votes

The proxy mechanism in UCP has been improved in the 12.2.0.1 to use dynamic proxies and will offer better performance than the Java's proxies that were used in 11.2.0.4. You will need to upgrade both ucp and jdbc (both have to be on the same version) to 12.2.0.1.