from what I see, Flyway when given a SQL file with some statements executes them one by one using ; as a delimiter (that is what I understood from SqlScript.execute()). Because of this applying patches on remote server takes a lot of time, because each statement of a file is send individually.
I wonder if that would be possible to do a “batch update” by sending the whole file in one piece and then apply it at once. Or maybe it is some JDBC constraint that we struggle against here?
Your observation is correct.
Flyway currently splits up files in single statements, which are then sent to the DBMS using JDBC.
Some DBMSs Jdbc Drivers, such as the ones from H2 and PostgreSQL, actually natively support sending more than one statement per jdbc call.
The reason I chose not to use this is that you trade error reporting quality for potential performance gains. On top of that, this solution would only be available to a minorty of users.
Batch updates could indeed be a cross-DBMS solution to this problem. Batching a whole file would probably not be the ideal, due to potential size explosion and the law of diminishing returns. Batching a few statements (say 20, 50, or whatever the sweet spot turns out to be) could prove valuable. This should not impact the code too much. In case the error reporting quality (which statement failed) is not measurably affected and performance improvements are visible, adding this should be a no-brainer.
Please raise an issue in the issue tracker if you would like to see this supported.