I am replacing the usage of JDBC Template with Jooq. For example, to batch update entities in a database. Against this I am running unit tests that use Quickperf annotations, as @ExpectUpdate
.
The batch size
in Jooq configuration is set to 100. Now, if I update 650 entities, I would expect 7 queries (650/100) to be executed. However, Quickperf tells me:
java.lang.AssertionError: a performance-related property is not respected
[PERF] Expected number of UPDATE statements <7> but is <1>.
while batch size seems to be 650 according to Quickperf:
[JDBC QUERY EXECUTION (executeQuery, executeBatch, ...)]
Time:42, Success:True, Type:Prepared, Batch:True, QuerySize:1, BatchSize:650, Query:["update...
With JDBC Template, this test would pass with @ExpectUpdate(7)
.
To update the records, I used Jooq method
dslContext.batchUpdate( updatableRecords ).execute()
. Then I tried with following Jooq method
dslContext.batched( c -> entities.forEach( entity -> c.dsl()
.update( table )
.set( table.tableFieldToUpdate, newValue )
.where( table.tableField.eq( someValue ) )
.execute() ) );
For the latter, the test passes, so batch size seems to be equal to 100 from Quickperf point of view.
Is this, by any chance, a bug in the Quickperf or am I missing something?
The Settings.batchSize
flag was introduced in jOOQ 3.14 with #3419, only for the BatchedConnection
. The assumption being that with a BatchedConnection
, it s hard to otherwise control the batch size, whereas with explicit batchUpdate()
calls, you can just chunk your List
and run a nested loop.
But it could indeed be convenient to either extend the flag's reach to other batch usage, or to add additional flags for those other batch API. I've created a feature request for this: #14840