一些firestore配额误解(Some firestore quotas misunderstandings)

我正在计划firestore中的db结构,并且无法理解一些标准点

链接: https : //firebase.google.com/docs/firestore/quotas

1点

这意味着在集合中复合索引的字段的db中的总内存大小?

3分

20000是否与文档中的最大字段数相似,因为由于doc,每个字段都会自动编入索引? 或者他们的意思是类似的

queryRef .where('field1', '<', someNumber1) ... .where('field20000', '<', someNumber20000);

对不起,我的英文不好

I'm planning a stucture of db in firestore and cannot understand some standard points

Link: https://firebase.google.com/docs/firestore/quotas

1 point

This means total memory size in db of fields which are composite indexed in collection?

3 point

Is 20000 similar to max count of fields in document because due to doc every field is automatically indexed? or they mean something like

queryRef .where('field1', '<', someNumber1) ... .where('field20000', '<', someNumber20000);

Sorry for my not good english

最满意答案

第1点

您可以在“ 存储大小计算”文档中查看大小的计算方式 。

索引条目大小

索引条目的大小是以下内容的总和:

索引文档的文档名称大小 索引字段大小的总和 如果索引是自动索引,则索引文档的集合ID的大小(不适用于复合索引) 32个附加字节

以具有数字ID的任务集合中的此文档为例:

Task id:5730082031140864 - "type": "Personal" - "done": false - "priority": 1

如果在类型+优先级(均为升序)上有复合索引,则此索引中索引条目的总大小为84个字节:

文档名称为29个字节 完成的字段名称和布尔值为6个字节 优先级字段名称和整数值的17个字节 32个附加字节

第2点

对于单字段索引(我们自动创建的索引),我们为每个字段创建2个索引:升序+降序。

这意味着10000个字段将达到20000索引条目限制,因此10000个字段是当前最大值。 如果您还有复合索引,则会减少,因为它会占用每个文档的20000个索引条目限制。

Point 1

You can see how size is calculated in the Storage Size Calculation documentation.

Index entry size

The size of an index entry is the sum of:

The document name size of the indexed document The sum of the indexed field sizes The size of the indexed document's collection ID if the index is an automatic index (does not apply to composite indexes) 32 additional bytes

Using this document in a Task collection with a numeric ID as an example:

Task id:5730082031140864 - "type": "Personal" - "done": false - "priority": 1

If you have a composite index on type + priority (both ascending), the total size of the index entry in this index is 84 bytes:

29 bytes for the document name 6 bytes for the done field name and boolean value 17 bytes for the priority field name and integer value 32 additional bytes

Point 2

For single field indexes (the ones we automatically create), we create 2 indexes per field: ascending + descending.

This means 10000 fields will hit the 20000 index entry limit, so 10000 fields is the current maximum. Less if you also have composite indexes since it will consume some of the 20000 index entry limit per document.

更多推荐