gpt4 book ai didi

firebase - Cloud Firestore 子集合是否包含在文档大小计算中

转载 作者:行者123 更新时间:2023-12-02 19:38:10 30 4
gpt4 key购买 nike

如果 Cloud Firestore 中的文档有子集合,这些子集合中的文档是否包含在父文档的大小中?例如,如果我有如下数据:

rootCollection/
parentDocument:
field1: "value1"
field2: "value2"
...
subCollection/
childDocument:
anotherField: "OfGreen"
...

childDocument 的大小包含在 parentDocument 的大小中

来自storage size calculation documentation ,听起来子集合的内容并不包含在父文档大小中,但我只是想澄清一下。

谢谢!

最佳答案

@frank-van-puffelen 已经说过了,但我想重申并分享官方引用资料以进一步强调。

TL;DR;

子集合的大小不会以任何方式影响父文档的大小。

引用文献

Firestore 的 Choose a Data Structure该文档是比较设计方案的非常清晰和及时的引用。在此页面的 Subcollections 部分下,指出:

Advantages: As your lists grow, the size of the parent document doesn't change. You also get full query capabilities on subcollections.

此外,关于Working with Arrays, Lists, and Sets Limitations下的文档部分,强调:

Document size - Cloud Firestore is optimized for small documents and enforces a 1MB size limit on documents. If your array can expand arbitrarily, it is better to use a subcollection, which has better scaling performance.

最后,虽然它与问题没有直接关系,但我想利用这个机会在这里提到它,因为当我得到与OP相同的问题时,它让我找到了正确的文档页面:ecgan/firestore-considerations是 Github 上的一个简短而引人注目的列表,它试图总结 Firestore 的注意事项和事先注意事项。

关于firebase - Cloud Firestore 子集合是否包含在文档大小计算中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47522984/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com