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

Ensure batch inserts on SQLite run in a transaction #1183

Merged
merged 1 commit into from Sep 22, 2017

Conversation

sgrif
Copy link
Member

@sgrif sgrif commented Sep 21, 2017

While it's safe for us to do the inserts one query at a time, due to the
lack of round-trip time on SQLite, there's still a significant
performance difference if done outside of a transaction. If we're not in
a transaction, SQLite will perform table locking, and file IO for each
query individually.

This also means that batch insert on SQLite will have the same semantics
on failure as the other backends.

While I previously thought that we did not want a savepoint here if we
were already in a transaction, it's actually important that we create
one in order to match the semantics of other backends on failure.

Fixes #1177.

@sgrif sgrif requested a review from a team September 21, 2017 15:54
@sgrif sgrif force-pushed the sg-ensure-sqlite-in-transaction branch 3 times, most recently from 88b7412 to b0cf840 Compare September 21, 2017 20:10
While it's safe for us to do the inserts one query at a time, due to the
lack of round-trip time on SQLite, there's still a significant
performance difference if done outside of a transaction. If we're not in
a transaction, SQLite will perform table locking, and file IO for each
query individually.

This also means that batch insert on SQLite will have the same semantics
on failure as the other backends.

While I previously thought that we did not want a savepoint here if we
were already in a transaction, it's actually important that we create
one in order to match the semantics of other backends on failure.

Fixes #1177.
@sgrif sgrif force-pushed the sg-ensure-sqlite-in-transaction branch from b0cf840 to 59f59e3 Compare September 21, 2017 22:47
Copy link
Contributor

@alexcameron89 alexcameron89 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@killercup killercup left a comment

Choose a reason for hiding this comment

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

LGTM

@killercup killercup merged commit 832cb27 into master Sep 22, 2017
@sgrif sgrif deleted the sg-ensure-sqlite-in-transaction branch September 22, 2017 14:41
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.

None yet

4 participants