skip to Main Content

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.

  1. Make those collections in the top most level of the database hierarchy.

  2. 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


  1. 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:

    Any documents in subcollections under the document, for example users/jeff/tasks/my_task_id/comments/D8PvloqiczrzXik3SWjZ, aren’t counted towards the document name size or the 1 MiB limit for the users/jeff/tasks/my_task_id document.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search