Improve network latency of runTransaction()
routine
#2015
Labels
api: firestore
Issues related to the googleapis/nodejs-firestore API.
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
If I correctly understand the routine for
runTransaction()
, as referenced below, then when running a read-write transaction, adocuments:beginTransaction
request is always issued before running theupdateFn
.nodejs-firestore/dev/src/transaction.ts
Lines 593 to 598 in e598b9d
This means we wait for an entire network round trip before beginning the transaction, every attempt.
I also noticed that the
documents:runQuery
anddocuments:batchGet
APIs support anewTransaction
parameter, which would allow the SDK to lazily start a transaction on the first read request, without the additional sequential network round trip.Lazily starting the transaction on the first read would always eliminate one entire sequential network round trip for every read-write transaction. I feel that this is quite a significant impact for high performance applications.
Some implications
documents:beginTransaction
and usenewTransaction
).documents:batchGet
,documents:runQuery
,documents: runAggregationQuery
(i.e. notdocuments:get
) which is fine.getAll()
. The only exception is if there is a mix of document IDs and queries (cannot be batched together in one request). Regardless, currently all reads are queued after thedocuments:beginTransaction
call anyways so there is no downside.documents:commit
is called without a transaction.Thoughts?
The text was updated successfully, but these errors were encountered: