Some firestore quotas misunderstandings

2019-04-10 20:49发布

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

enter image description here

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条回答
三岁会撩人
2楼-- · 2019-04-10 21:06

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.

查看更多
登录 后发表回答