-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use multiStatement to apply DML #1462
Conversation
tx, err := conn.BeginTx(ctx, nil) | ||
if err != nil { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have the BEGIN
statement be the first in the list of the multistatement and avoid the network roundtrip for this.
SET SESSION
can happen before the BEGIN
now. The reason why it was done inside of the transaction was to ensure that it happens on the same connection, but we're now explicitly checking out the connection out of the database pool.
go/logic/applier.go
Outdated
// each DML is either a single insert (delta +1), update (delta +0) or delete (delta -1). | ||
// multiplying by the rows actually affected (either 0 or 1) will give an accurate row delta for this DML event | ||
for i, rowsAffected := range mysqlRes.AllRowsAffected() { | ||
totalDelta += rowDeltas[i] * rowsAffected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we add BEGIN
to the multi statement, this calculation here will need to be updated accordingly.
Another screenshot showing the improvement over a longer time period. @meiji163 Great work! |
Description
This PR changes the Applier to batch together DML statements into multi-statements in order to reduce the number of network trips in
ApplyDMLEventQueries
.During testing on our
--test-on-replica
setup this provided around 10% increase in rows/second throughputRows Modified (rate);
dml-batch-size=10
script/cibuild
returns with no formatting errors, build errors or unit test errors.