Skip to content
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

Optimised copy full batches #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Optimised copy full batches #12

wants to merge 2 commits into from

Conversation

koszti
Copy link

@koszti koszti commented Oct 16, 2018

Replicating from Binary-Log with incoming UPDATES (hence multiple versions of the row with the same PK) calls intermediate flush_records to avoid issues with upserts.

This method works fine but if the replication BinLog has a lot of updates then it produces a lot of unnecessary COPY/INSERT/UPDATE commands with small number of rows which is not efficient.

This PR keeps the incoming rows in python dictionaries where dict key is the Primary Key of the rows. If a new version of the row arrives then it will update the values in the python dictionary without hitting the database. flush_records will be called only when the batch is full and in the last loop.

@airhorns
Copy link

👍 this would be great to get in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants