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

reuse prepared statement in multi_insert #11

Merged
merged 1 commit into from
Jul 31, 2024
Merged

reuse prepared statement in multi_insert #11

merged 1 commit into from
Jul 31, 2024

Conversation

matt-codecov
Copy link
Collaborator

@matt-codecov matt-codecov commented Jul 30, 2024

currently, if Page 2 is the same size as Page 1, we'll reuse the String with the query in it but we still go through the rusqlite statement cache to get the prepared statement. profile data showed if we spent ~4 seconds in Statement::execute_with_bound_parameters() we were spending ~2 seconds in StatementCache::get(), which can probably be reclaimed

this PR reuses the actual PreparedStatement between loop iterations. it also skips clearing the prepared statement cache at the end of the function, which seems to drive most of the time savings. with my unscientific local testing, this appears to save a little less than 1s for my 110mb pyreport, going from a little less than 9s to about 8s

Copy link

codecov bot commented Jul 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.19%. Comparing base (c0a4b65) to head (3b243d5).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
- Coverage   99.21%   99.19%   -0.02%     
==========================================
  Files          17       17              
  Lines        7249     7249              
==========================================
- Hits         7192     7191       -1     
- Misses         57       58       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@joseph-sentry joseph-sentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about not clearing the cache (is this just going to cost us in memory?) but for the most part lgtm

Copy link
Collaborator

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, I will rebase my own PR on this one, I think there is a middle ground to be found here.

@matt-codecov matt-codecov merged commit 7b90e15 into main Jul 31, 2024
5 of 6 checks passed
@matt-codecov matt-codecov deleted the pr11 branch July 31, 2024 16:46
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.

3 participants