The official documentation says that the max size of a document is 1MB. My question is that does this size affect the number of Sub Collections I can make inside that document?
This answer says that the size of the sub collections does not affect the document size. But I am concerned about the Number of sub collections I can make.
In my project I have to make around 1000 collections. Currently I have two options.
-
Make those collections in the top most level of the database hierarchy.
-
Make a document and then make the collections inside that document as sub collections.
I want to go with option 2, however I am concerned that in the future the document size limit might affect how many collections I can make inside.
I have read the documentation but can’t find relatable answer.
2
Answers
As stated in the answer you linked: the data in subcollections under a document, does not count towards the size of that parent document.
From the documentation on document size calculation:
In addition to Frank‘s answer, note that "collections" and "subcollections" do not exist as objects in Firestore. They are a grouping & querying concept.
As this article that I wrote outlines, Firestore only has Documents.