Storage size calculations

This page describes the storage size of documents, document names, fields, and index entries in Firestore.

You can learn about the costs of this storage at Firestore Pricing.

String size

String sizes are calculated as the number of UTF-8 encoded bytes + 1.

The following are stored as strings:

  • Collection IDs
  • String document IDs
  • Document names
  • Field names
  • String field values

For example:

  • The collection ID tasks uses 5 bytes + 1 byte, for a total of 6 bytes.
  • The field name description uses 11 bytes + 1 byte, for a total of 12 bytes.

Document ID size

The size of a document ID is either the string size for a string ID or 8 bytes for an integer ID.

Document name size

The size of a document name is the sum of:

  • The size of each collection ID and document ID in the path to the document
  • 16 additional bytes

For a document in the subcollection users/jeff/tasks with a string document ID of my_task_id, the document name size is 6 + 5 + 6 + 11 + 16 = 44 bytes:

  • 6 bytes for the users collection ID
  • 5 bytes for the jeff document ID
  • 6 bytes for the tasks collection ID
  • 11 bytes for the my_task_id document ID
  • 16 additional bytes

Field value size

The following table shows the size of field values by type.

Type Size
Array The sum of the sizes of its values
Boolean 1 byte
Bytes Byte length
Date and time 8 bytes
Floating-point number 8 bytes
Geographical point 16 bytes
Integer 8 bytes
Map The size of the map, calculated the same way as document size
Null 1 byte
Reference The document name size
Text string Number of UTF-8 encoded bytes + 1
Vector 8 bytes per dimension

For example, a boolean field named done would use 6 bytes:

  • 5 bytes for the done field name
  • 1 byte for the boolean value

Document size

The size of a document is the sum of:

This example is for a document in subcollection users/jeff/tasks with a string document ID of my_task_id:

 - "type": "Personal"
 - "done": false
 - "priority": 1
 - "description": "Learn Cloud Firestore"

The total size of the fields is 71 bytes:

Field name and value Field size in bytes
"type": "Personal" 14
5 for the field name + 9 for the field's string value
"done": false 6
5 for the field name + 1 for the field's boolean value
"priority": 1 17
9 for the field name + 8 for the field's integer value
"description": "Learn Cloud Firestore" 34
12 for the field name + 22 for the field's string value

So the document size is 44 + 71 + 32 = 147 bytes:

  • 44 bytes for the document name
  • 71 bytes for the fields
  • 32 additional bytes

Index entry size

Index entry sizes are calculated as follows for single-field and composite indexes.

Single-field index entry size

The size of a single-field index entry depends on whether an index is scoped to a collection or a collection group.

Collection scope

The size of an entry in a single-field index with collection scope is the sum of:

Consider a document in the sub-collection users/jeff/tasks with a string document ID of my_task_id:

 - "type": "Personal"
 - "done": false
 - "priority": 1
 - "description": "Learn Cloud Firestore"

For a single-field index with collection scope that indexes the done field, the total size of the entry in this index is 109 bytes:

  • 44 bytes for the document name users/jeff/tasks/my_task_id
  • 27 bytes for the parent document's document name users/jeff
  • 5 bytes for the done field name
  • 1 byte for the boolean field value
  • 32 additional bytes

Collection group scope

The size of an entry in a single-field index with collection group scope is the sum of:

Consider a document in the sub-collection users/jeff/tasks with a string document ID of my_task_id:

 - "type": "Personal"
 - "done": false
 - "priority": 1
 - "description": "Learn Cloud Firestore"

For a single-field index with collection group scope that indexes the done field, the total size of the entry in this index is 98 bytes:

  • 44 bytes for the document name users/jeff/tasks/my_task_id
  • 5 bytes for the done field name
  • 1 byte for the boolean field value
  • 48 additional bytes

Composite index entry size

The size of an entry in a composite index depends on whether the index is scoped to a collection or a collection group.

Collection scope

The size of an index entry in a composite index with collection scope is the sum of:

Consider a document in the sub-collection users/jeff/tasks with a string document ID of my_task_id:

 - "type": "Personal"
 - "done": false
 - "priority": 1
 - "description": "Learn Cloud Firestore"

For a composite index with collection scope that indexes the done and priority fields (both ascending), the total size of the entry in this index is 112 bytes:

  • 44 bytes for the document name users/jeff/tasks/my_task_id
  • 27 bytes for the parent document's document name users/jeff
  • 1 byte for the boolean field value
  • 8 bytes for the integer field value
  • 32 additional bytes

Collection group scope

The size of an index entry in a composite index with collection group scope is the sum of:

Consider a document in the sub-collection users/jeff/tasks with a string document ID of my_task_id:

 - "type": "Personal"
 - "done": false
 - "priority": 1
 - "description": "Learn Cloud Firestore"

For a composite index with collection group scope that indexes the done and priority fields (both ascending), the total size of the index entry in this index is 85 bytes:

  • 44 bytes for the document name users/jeff/tasks/my_task_id
  • 1 byte for the boolean field value
  • 8 bytes for the integer field value
  • 32 additional bytes

What's next

Learn about Firestore pricing.