go-sql-driver / go-sql-driver/mysql

feature request : MariaDB pipeline PREPARE + EXECUTE

Open
#1,689 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
15.3k
Forks
2.3k
Avg merge
2h 23m
Merged PRs (30d)
10

Description

_this feature request is part of a serie to improve performance when using MariaDB : see [doc](https://mariadb.com/kb/en/mariadb-protocol-differences-with-mysql/#mariadb-capabilities-extension)_

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](https://mariadb.com/kb/en/com_stmt_prepare/) command to the server, receiving a statement ID in response.
> Execute: Send a [COM_STMT_EXECUTE](https://mariadb.com/kb/en/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](https://mariadb.com/kb/en/what-is-mariadb-102/)), 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](https://mariadb.com/kb/en/com_stmt_prepare/) then a [COM_STMT_EXECUTE](https://mariadb.com/kb/en/com_stmt_execute/) with statement ID -1 (0xffffffff) commands to the server.
> Read the prepare and execute responses
> If the [COM_STMT_PREPARE](https://mariadb.com/kb/en/com_stmt_prepare/) command returns an error (ERR_Packet), the subsequent [COM_STMT_EXECUTE](https://mariadb.com/kb/en/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](https://mariadb.com/kb/en/com_stmt_prepare/), wait for results, then execute [COM_STMT_EXECUTE](https://mariadb.com/kb/en/com_stmt_execute/) with statement_id received from the prepare result.
>
> This description has been done for [COM_STMT_EXECUTE](https://mariadb.com/kb/en/com_stmt_execute/), but [COM_STMT_BULK_EXECUTE](https://mariadb.com/kb/en/com_stmt_bulk_execute/) works exactly the same way.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.