Our JDBC driver implements technique called protocol pipelining, which is sends multiple (N) requests at once (they can be normal query COM_QUERY, COM_STMT_EXECUTE, and mix of those ), and only then waits for N responses to come back.
Both normal statements and prepared statements can be batched. This , according to JDBC spec is only used for updates statements.
JDBC driver optimizes sending on its part, however server could help to further optimize the pipelining. The problem is that server does not use TCP efficiently in this case, and (since it unconditionally disables Nagle algorithm), packs a lot (tens of thousands) tiny OK packets into large TCP segments.
The task is to make Nagle possible again, via a session variable. client would add 2 COM_QUERY packets to batch, "set session tcp_nodelay=0" prepends the batch, and "set session tcp_nodelay=1" at the end, optimizing TCP communication.