Skip to content

Would it make sense to batch upserts? #1298

Answered by simolus3
mattsimgithub asked this question in Q&A
Discussion options

You must be logged in to vote

I do think that upserts make sense in a batch. In moor, a batch is essentially doing two things:

  1. It wraps all statement in a transaction.
  2. It re-uses prepared statement to avoid duplicate parsing costs.

Point 1 is typically the major factor to increase throughput. Creating a transaction for each write can be a bit slow, grouping writes in a transaction improves performance a lot. Point 2 also improves performance a bit further, but not as much as the implicit transaction used in a batch.

So yes, in general it always makes sense to use batches when you have a group of writes that you want to run.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mattsimgithub
Comment options

Answer selected by mattsimgithub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants