DbUtils Query runner usage of batch performance

56 views Asked by At

We have an application which selects rows from database based on a status, processes it and updates the status, so that it is not picked up again. We have been using Apache DBUtils Query Runner to execute the queries and to caste the items to a bean using a bean handler.

We have been using queryRunner.update(Connection, updateQuery) by giving a query which updates based on 'ID's using 'IN' clause.

UPDATE TABLE SET STATUS = 'P' WHERE ID IN ('id1', 'id2'....);

But we realized that Oracle has a limitation of 1000 items to keep in the 'IN' clause but we wanted to try selecting more records and update them. This is because as the fetch count increased, we noticed better performance.

So we thought of using,

public int[] batch(Connection conn,
                   String sql,
                   Object[][] params)
            throws SQLException;

and pass the 'ID's in the params.

I would like to know the below,

  1. In a plain select and update, which one will perform better, a. Low fetch count and update using IN with lesser items. (higher number of loops). b. Higher fetch count and update using IN with higher items. (lower number of loops).
  2. Does QueryRunner.batch have the limitation of 1000 items in 'IN' statement or does it use a different mechanism?
  3. Does QueryRunner.batch actually update one by one and end up performing worse than using 'IN' clause?

Kindly help me here. Apologies for multiple questions.

0

There are 0 answers