Benefits of Firestore Subnets

The firestore docs do not have a detailed discussion of the trade-offs associated with using subcategories and top-level collections, but note that they are less flexible and less "scalable." Given that you sacrifice the flexibility of customizing your data in subcategories, there must be certain positive aspects to the mental structure as well.

For example, how does the time for a single-key firestore request in a large collection compare to getting all the elements from a much smaller collection?

Say we want to request a large collection of "People" for all people in the family unit. Alternatively, break down family data primarily into family units.

People → People: {family: 'Smith'}

against

Families → Family: {Name: 'Smith'} → People → People

I would expect the latter to be more effective, but is this true? Are there any large O scores for everyone? Any other benefits of subcategories (e.g. for transactions)?

+14
source share
2 answers

I have some key points in the subcollections that you need to know when modeling a database.

1 - Subcollections provide you with a more structured database.

2 - Queries are indexed by default: Query performance is proportional to the size of your result set, not the data set. So no matter the size of your collection, performance depends on the size of your result set.

3 - 1 . , , , , ​​ . , .

4 - : Firestore , . , , , , .

+7

. . , . , , .

:

:

  • "" , .
  • / / , . .

:

  • . , . API, .
  • () , .
-1

Source: https://habr.com/ru/post/1688980/


All Articles