Batch
Published 31 October 2023
Batch
Description
Whether to batch SQL statements when executing them. Batching can save up to 99 percent of network roundtrips by sending up to 100 statements at once over the network to the database, instead of sending each statement individually.
This is particularly useful for very large SQL migrations composed of multiple MB or even GB of reference data, as this can dramatically reduce the network overhead.
This is supported for INSERT, UPDATE, DELETE, MERGE, and UPSERT statements. All other statements are automatically executed without batching.
Default
false
Usage
Commandline
./flyway -batch="true" info
TOML Configuration File
[flyway]
batch = true
Configuration File
flyway.batch=true
Environment Variable
FLYWAY_BATCH=true
API
Flyway.configure()
.batch(true)
.load()
Gradle
flyway {
batch = true
}
Maven
<configuration>
<batch>true</batch>
</configuration>
Use Cases
Improving performance by reducing communication overhead
Suppose you have 1000 statements in a migration, and your communication overhead is 0.1 second. Without batching the migrate process would have a 1000 x 0.1 = 100 second overhead in communication (sending the statements) alone. This is a lot of time. With batch
enabled, 100 statements can be sent at a time, meaning the communication overhead is only incurred 1000/100 = 10 times, resulting in a 10 x 0.1 = 1 second migrate overhead due to communication.