5

I have read the docs regarding transactional update operations on Firestore. According to Quotas and Limits there are only two limits with regards to transactions:

  • Maximum size for a transaction: 10 MiB
  • Time limit for a transaction: 270 seconds, with a 60-second idle expiration time

There is no explicitly transaction-related limit mentioned, how many documents or collections can be read and/or modified during the transaction, or if there are any additional constraints on the collections in which the transactional updates happen.

  1. Does it mean, a client could do a transactional update on up to 500 documents, each in different collections, as long as the update stays inside these and the other general limits?

  2. If a client reads multiple documents inside a transaction, but only updates one of them - does Firestore still (silently) write into the unmodified documents (for serialization or so)... so I have to consider the write-limit of 1 write per document per second even for documents that have not been explicitly modified by the client.

P.S.: The reason I ask is that Datastore has a limit of 25 entity-groups in transactions, and also sees hotspots in entities ("documents") that are read-only inside many write transactions. For example, see this answer by Dan McGrath. I just wonder which of Datastore's characteristics carry over to Firestore and has to be considered when designing a Firestore database.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
Ani
  • 1,377
  • 1
  • 18
  • 29

1 Answers1

5

See the line "Maximum number of documents that can be passed to a Commit operation" which defines a limit of 500 documents. This is your transaction limit as we need to apply everything in a transaction using a single commit.

I don't believe silent writes are required anymore to determine if a document has changed in a transaction.

There is no related limit that is equivalent to the 25 entity-group limit.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
  • 2
    In case that we will want to do more than 500 updates, we should use multiple batchs? or how we can achieve this? I have a case where I need to update a `reference` dinamically for an `User Feed`. Where I add to a collection the Id's + some info of each `Post` made by the user I follow, and ofc I need to delete this refs if I unfollow the user. Right now everything works fine, but if in a future my app grows and an user have more than 500 post, my `cloud function` will crash when trying to update this data. – Francisco Durdin Garcia Oct 17 '17 at 16:10
  • 1
    @FranciscoDurdinGarcia Honestly, if you store even just a reference to every post of every user that user X followed in a collection inside user X you have bigger scalability problems than transaction limits. – Mihail Malostanidis Aug 15 '18 at 22:44