Rafał Kuźmiński
12/14/2023, 11:51 AMwith(databaseConnection) {
val config = HikariConfig().apply {
jdbcUrl = databaseUrl
driverClassName = driver.driverClass
username = user.userName
password = user.password
maximumPoolSize = 20
}
val dataSource = HikariDataSource(config)
Database.connect(dataSource)
}
But still, nothing changed, postgres is using only one core. I think that I have to create multiple transactions to force new connections? For context I'll add simplified code of SQL execution:
suspend fun executeSqls(sqlList: List<String>) {
newSuspendedTransaction {
val transaction = this
val coroutineContext = Dispatchers.IO.limitedParallelism(20)
sqlList.forEachParallel(coroutineContext) { sql -> transaction.exec(sql) }
}
}
Probably executing newSuspendedTransaction for every sql is a bad idea? Should I split my list of sqls in parts and then use single transaction for one part?Rafał Kuźmiński
12/14/2023, 12:14 PMAdamW
12/14/2023, 5:37 PMTransactionInterface
- so to obtain connections concurrently, you would make multiple calls to one of the transaction builders 👍AdamW
12/14/2023, 5:40 PM