Skip to content

feature request : MariaDB pipeline PREPARE + EXECUTE #1689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rusher opened this issue Mar 26, 2025 · 0 comments
Open

feature request : MariaDB pipeline PREPARE + EXECUTE #1689

rusher opened this issue Mar 26, 2025 · 0 comments

Comments

@rusher
Copy link
Contributor

rusher commented Mar 26, 2025

this feature request is part of a serie to improve performance when using MariaDB : see doc

MariaDB (since 10.2) permit sending COM_STMT_PREPARE + COM_STMT_EXECUTE directly, without having to wait for prepare, this permit faster first execution. It wpuld be great to have that !

from https://mariadb.com/kb/en/mariadb-protocol-differences-with-mysql/#pipelining-prepare-execute

Connectors usually follow a two-step process for prepared statements:

Prepare: Send a COM_STMT_PREPARE command to the server, receiving a statement ID in response.
Execute: Send a COM_STMT_EXECUTE command, using the statement ID obtained in the previous step.
When the server support MARIADB_CLIENT_STMT_BULK_OPERATIONS capability (since MariaDB 10.2), a specific statement ID value of -1 (or 0xffffffff in hexadecimal) can be used to indicate that the previously prepared statement could be reused. This enables connectors to pipeline the preparation and execution steps into a single request:

Send a COM_STMT_PREPARE then a COM_STMT_EXECUTE with statement ID -1 (0xffffffff) commands to the server.
Read the prepare and execute responses
If the COM_STMT_PREPARE command returns an error (ERR_Packet), the subsequent COM_STMT_EXECUTE with statement ID -1 will also fail and return an error.

By eliminating the round trip for the separate COM_STMT_EXECUTE command, this approach improves performance for the first execution.

Traditionally, connectors send COM_STMT_PREPARE, wait for results, then execute COM_STMT_EXECUTE with statement_id received from the prepare result.

This description has been done for COM_STMT_EXECUTE, but COM_STMT_BULK_EXECUTE works exactly the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant