Repository navigation
perf(mysql): cut USE, row cap and column read round trips - #4341
Merged
Merged
Conversation
… compare database names by bytes
datlechin
enabled auto-merge (squash)
November 19, 2026 06:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
USEthe host sends before each statement is left out while the session is proven on that database. The proof lives on the connection and advances on its serial queue: only a statement headedSELECT,INSERT,UPDATE,DELETE,REPLACE,SHOW,DESC,EXPLAIN,WITH,VALUES,TABLEorDO, with no executable comment and no second statement, keeps it. Anything else sends theUSE. The skip also needs the driver's active database to match and a clean footprint, on MySQL and MariaDB only, never behind a proxy that names itself.MySQLSessionFootprintnow seesUSE`db`,USE/* c */db,/*!40101 */ /*!40101 USE db */,CALLwith no space, MariaDBEXECUTE IMMEDIATEand compound blocks, somysqlMayReplayno longer replays after a move it missed. One forward pass, no recursion; past 32 version comments a statement counts as opaque.USEno longer resetsROW_COUNT()or the warning list, so they answer for the user's own last statement. With a row cap installed, the next statement still gets the reset thatUSEused to trigger.SET SQL_SELECT_LIMITand the read in one flight. WhichSETgoes out is unchanged from main, so diagnostics read the same. A refused cap reads the statement's own answer, as main does, and Stop keeps killing until the read is done.fetchColumnssendsSHOW FULL COLUMNS, the catalog read, MariaDB'sLEVELprobe and the check clauses in one flight. Stop never ends the session: it sends the sameKILL QUERYagain every 250 ms until every reply is read, under the connection's queue, so a queuedCOMMITwaits. Each reply's error comes from that reply. Only a client error retires the session. A session in a transaction or holding anything in its footprint reads one by one.DatabaseManager+ScopedDriver.swift: the comment on the database switch says the driver now decides whetherUSEgoes out.check-column-type-corpus.sh: links the products and shared files the MySQL plugin and the export plugins need, so the MySQL and MariaDB corpus builds again.Measured through a 200 ms round trip proxy, scratch MariaDB 13.0.2 and MySQL 8.4.11. Milliseconds, then statements sent.
LIMIT, repeatedTest plan
MySQLDatabaseMoveScanTests,MySQLColumnFlightTests. Added cases inMySQLSelectLimitTestsandMySQLServerVersionTests. The footprint cases for the fourUSEspellings andEXECUTE IMMEDIATEfail on main.USEspelling,init_connect, the session's own and another client'sDROP DATABASE, a stored function that moves the limit,ROW_COUNT(),SHOW WARNINGSandFOUND_ROWS()compared with main, a refused read inside a flight, a session killed mid-flight, temporary tables, transactions,NO_BACKSLASH_ESCAPES, Stop on queuedSLEEPreads and on capped reads, Stop mid-flight through the proxy.