'How do I manually calculate the Firestore automatic index size?
I'm relatively new to Firebase and I'm looking to calculate how much data I incur from automatically created single-field indexes on Firestore native mode. I understand that the rule of thumb is to go through and exempt fields and there are guidelines on this. However, I am more interested in how much data is actually calculated as an overhead if I don't exempt any fields.
I am looking for someone to verify my math. I used the rules outlined here https://firebase.google.com/docs/firestore/storage-size. This is what I have
Document size is the sum of:
The document name size = 48 bytes
The sum of the string size of each field name = Average of 9 bytes * 97 attributes=873
The sum of the size of each field value = Average of 70 bytes * 97 attributes=6790
32 additional bytes
Document size 48+873+6790+32 =7,743 bytes
Collection size = (doc size) * (# of docs) 7,743*130 = 1MB
Single-field index with collection scope is the sum of:
The document name size of the indexed document = 48 bytes
The document name size of the indexed document's parent document = 0
The string size of the indexed field name = 9 bytes
The size of the indexed field value = 70 bytes
32 additional bytes
Single-field index size on the average attribute = (48+9+70+32) = 159 bytes
Single field index with 130 documents= 159*130=20,670 bytes
Automatically created ascending and descending indexes 20,670*2 = 41,340 bytes
Single field index for 97 attributes 41,340*97=4MB
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
