Use multiStatement to apply DML#1462
Merged
arthurschreiber merged 6 commits intomasterfrom Oct 25, 2024
Merged
Conversation
arthurschreiber
previously approved these changes
Oct 24, 2024
Comment on lines
+1222
to
+1225
| tx, err := conn.BeginTx(ctx, nil) | ||
| if err != nil { | ||
| return err | ||
| } |
Contributor
There was a problem hiding this comment.
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 |
Contributor
There was a problem hiding this comment.
if we add BEGIN to the multi statement, this calculation here will need to be updated accordingly.
arthurschreiber
approved these changes
Oct 25, 2024
Contributor
Another screenshot showing the improvement over a longer time period. @meiji163 Great work! |
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.

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-replicasetup this provided around 10% increase in rows/second throughputRows Modified (rate);

dml-batch-size=10script/cibuildreturns with no formatting errors, build errors or unit test errors.