Reputation: 10844
In the Cloud Firestore - Best Practices documentation the first line reads:
You should not update a single document more than once per second. If you update a document too quickly, then your application will experience contention, including higher latency, timeouts, and other errors.
I have a database structure like this:
My app manages an inventory of lockers that people can check-in & check-out in real-time. My concern is if I am limited to "one write per document per second" and my locker documents are in a sub-collection of the storage document. Does that mean I am limited to only updating one locker at a time per second or can I update many locker documents at the same time?
My hope is that since the locker documents are in a sub-collection I can read/write to many individual lockers at the same time. My fear is that they are considered part of one document (the storage document) and I can only read/write to one locker at time.
Upvotes: 0
Views: 383
Reputation: 26313
Subcollections are a logical hierarchy, not a structural one. Per-document write limits apply to each document in the subcollection, not all of them together. So in your case, each locker should only be updated once per second, but many lockers may be updated at once without trouble.
Upvotes: 2