You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: inline BeginTransaction with first statement (#466)
* perf: inline BeginTransaction with first statement
Inline the BeginTransaction option with the first statement in the transaction,
instead of executing a separate BeginTransaction RPC. This reduces the number
of round-trips to Spanner by one for all transactions that have at least one
SQL statement.
Using line-begin improves performance for most transaction shapes, as it requires
one less round-trip to Spanner. Some transaction shapes do not benefit from this.
These are:
1. Transactions that only write mutations still need an explicit BeginTransaction
RPC to be executed, as mutations are included in the Commit RPC. The Commit
RPC can also start a transaction, but such transactions are not guaranteed to
be applied only once to Spanner.
2. Transactions that execute multiple parallel queries at the start of the
transaction can see higher end-to-end execution times, as only one query
can include the BeginTransaction option. All other queries must wait for
the first query to return at least one result, which also includes the
transaction identifier, before they can proceed.
The default for the database/sql driver is to use inline-begin.
A follow-up pull request will add an option to the driver to set a different
default for a connection.
* feat: add BeginTransactionOption (#467)
Adds a BeginTransactionOption configuration field that can be used to
determine how the database/sql driver should begin transactions. The
default is to inline the BeginTransaction option with the first SQL
statement of the transaction. This reduces the number of round-trips
needed per transaction by one for most transaction shapes.
0 commit comments