perf: database connection pooling

This commit is contained in:
Gauthier Roebroeck 2022-07-20 10:08:25 +08:00
parent 3256f3f300
commit 58fde3e7aa
2 changed files with 8 additions and 1 deletions

View file

@ -70,6 +70,9 @@ class KomgaProperties {
@get:Positive
var batchChunkSize: Int = 1000
@get:Positive
var maxPoolSize: Int = 8
}
class Lucene {

View file

@ -24,11 +24,15 @@ class DataSourcesConfiguration(
.type(SqliteUdfDataSource::class.java)
.build()
val poolSize =
if (komgaProperties.database.file.contains(":memory:")) 1
else Runtime.getRuntime().availableProcessors().coerceAtMost(komgaProperties.database.maxPoolSize)
return HikariDataSource(
HikariConfig().apply {
dataSource = sqliteUdfDataSource
poolName = "SqliteUdfPool"
maximumPoolSize = 1
maximumPoolSize = poolSize
},
)
}