Batch Control
SqlClient supports two configurations: DefaultBatchSize
and DefaultListBatchSize
. If not configured, the default values are 128 and 16.
These two configurations provide default values for the batchSize in Object Fetcher. Their effects have been described in detail in Object Fetcher, so this article only explains the configuration without repeating the explanation of their effects.
There are two ways to set these configurations:
- Use Spring Boot Starter
- Don't use Spring Boot Starter
Use Spring Boot Starter
jimmer:
default-batch-size: 256
default-list-batch-size: 32
Don't use Spring Boot Starter
- Java
- Kotlin
@Bean
public JSqlClient sqlClient() {
return JSqlClient
.newBuilder()
.setConnectionManager(...)
.setDialect(new H2Dialect())
.setExecutor(...)
.addScalarProvider(...)
.setDefaultBatchSize(256)
.setDefaultListBatchSize(32)
.build();
}
@Bean
fun sqlClient(): KSqlClient =
newKSqlClient {
setConnectionManager { ... }
setDialect(H2Dialect())
setExecutor { ... }
addScalarProvider { ... }
setDefaultBatchSize(256)
setDefaultListBatchSize(32)
}