JetBrains / Exposed

Kotlin SQL Framework
http://jetbrains.github.io/Exposed/
Apache License 2.0
8.37k stars 694 forks source link

batch size #1430

Open mixnix opened 2 years ago

mixnix commented 2 years ago

Does exposed support batch size setting for JDBC batch insert? When I insert many thousands of rows there is serious performance issue that could be fixed by that setting.

vlsi commented 1 year ago

Currently, Exposed buffers all the rows within a single list, so it effectively keeps the data in memory instead of passing it to the database: https://github.com/JetBrains/Exposed/blob/0.41.1/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/statements/BaseBatchInsertStatement.kt#L19

It might be nice to have something like batchSize: Int setting so batchInsert would automatically call executeBatch once in a while.