asyncer-io / r2dbc-mysql

Reactive Relational Database Connectivity for MySQL. The official successor to mirromutth/r2dbc-mysql(dev.miku:r2dbc-mysql).
https://r2dbc.io
Apache License 2.0
195 stars 21 forks source link

[feature]Add support for rewriteBatchedStatements feature in r2dbc-mysql #136

Open jchrys opened 1 year ago

jchrys commented 1 year ago

Is your feature request related to a problem? Please describe. Currently, there is no built-in support for rewriting batched statements, which results in performance issues when executing multiple statements as a batch.

Describe the solution you'd like I would like to request the addition of a feature similar to rewriteBatchedStatements in mysql-connector-j. This feature allows the driver to automatically rewrite batched statements into a single multi-row insert statement, improving performance and reducing the network round-trips.

The proposed solution would involve implementing a mechanism in r2dbc-mysql that analyzes batched statements and intelligently combines them into a single multi-row insert statement, thus optimizing the execution and reducing overhead.

Additional context Having support for the -rewriteBatchedStatements feature in r2dbc-mysql would greatly enhance the performance and efficiency of executing batched statements. This feature is already available in mysql-connector-j and is widely used by developers who work with JDBC.

https://dev.mysql.com/doc/connector-j/8.1/en/connector-j-connp-props-performance-extensions.html

mirromutth commented 8 months ago

A useful feature, this should require modifying Query.parse to determine whether the current statement is an INSERT or REPLACE that can be replaced, and to read the start/end indexes of valid VALUE/VALUES and the start/end indexes of subsequent brackets. In the final execution, the parentheses and the ? marks in the parentheses are multiplied by the size of bindings as a group.