Description
batch commit's do_append
now makes an efficient bulk insert via INSERT INTO .. SELECT FROM UNNEST(...)
instead of using spanner's mutation API.
In my local testing this performed similarly to a mutation bulk insert (if anything the mutation was slightly faster, but pretty much negligible).
Avoiding mutations is preferable as they don't play nicely with our unit tests' transactions. We've worked around this for put_bso
by implementing both mutation and individual INSERT
versions, with the mutation cfg
toggled off during tests.
put_bso
could definitely switch to this INSERT
instead of a mutation and it may be possible to implement an UPDATE
utilizing UNNEST(...)
in a similar fashion -- looking similar to batch_commit_update.sql but selecting from UNNEST(...)
instead of batch_bsos
-- and hopefully Spanner would optimize it efficiently.
If so we could remove the mutation impls entirely.