i wanted to ask if i make a initial collection (collection>document1>collection>document2), my question is will the document2 size be 1mb as well as the size of document1 = 1mb? total of 2mb or just 1mb for the entire document and sub collections and document dont count ?
Asked
Active
Viewed 42 times
1 Answers
0
No, it doesn't.
A document is stand-alone. The maximum 1MB quota on a document does not include documents in subcollections.
The above explains why we could have some "posts" subcollection in a "users" documents (let's say we are in a social media app). The posts by a given user would grow so much you know. You don't expect Firebase to prevent more creation of posts for the 1MB reason. I hope this further explains the answer.
It is worth mentioning that querying in Firestore is shallow. In other words, fetching a document doesn't recursively fetch all the other documents in subcollections.
Know more about Firestore Quotas here at https://cloud.google.com/firestore/quotas

Obum
- 1,485
- 3
- 7
- 20
-
so will fetching a document inside another document count as 2 document reads and ill be charged for 2 documents read? – Spicier Ewe Jul 19 '22 at 23:55
-
no it is one document read. It will count as 1. Let's say you are using `firestore.doc('collection1/doc1/collection2/doc2').get()` , you are just using the `get` method on a single doc to return just one document. In fact see it that every time the `.get` method is called on a `.doc` (and it successfully returns, then it is just one read. Irrespective of the document path. – Obum Jul 20 '22 at 00:04
-
just last question so as documetn is stand alone if ii have document2 inside a document1 then both the documents are stand alone? meaning no matter of the sub collections both the documts will have there own 1mb data size – Spicier Ewe Jul 20 '22 at 00:19
-
yes yes, now you understand it well. – Obum Jul 20 '22 at 00:33