This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 265
Use COPY to speed up database writes for blocks and traces #211
Merged
Conversation
This file contains 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
lukevs
changed the title
Use COPY to speed up database writes
Use COPY to speed up database writes for blocks and traces
Jan 4, 2022
lukevs
commented
Jan 4, 2022
|
||
def _inputs_as_json(trace) -> str: | ||
inputs = json.dumps(json.loads(trace.json(include={"inputs"}))["inputs"]) | ||
inputs_with_array = f"[{inputs}]" |
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.
this is because of this #209
kept it for now so the diffs work
will do a follow on to fix and backfill
taarushv
approved these changes
Jan 4, 2022
mendesfabio
pushed a commit
to mendesfabio/mev-inspect-py
that referenced
this pull request
Nov 21, 2022
Use COPY to speed up database writes for blocks and traces
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Following the advice of this guide (and using their string io helper)
https://hakibenita.com/fast-load-data-python-postgresql
Locally on a 30 block test this speeds up from 92.63 seconds to 77.5 seconds
I'll make follow on PRs for the other tables once we see how this performs in production
Will also mess around with our block batch size (hoping we can increase it with this)
Testing
To test, I wrote this to export all of the tables for a given block
Then wrote this bash script to compare exports across main and this branch
we check which code is deployed by checking for a
hello.txt
file i committed to this branch (then removed for review)