[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-19。"],[],[],null,["# Storage size calculations\n=========================\n\nThis page describes the storage size of documents, fields, and\nindex entries in Firestore with MongoDB compatibility.\n\nYou can learn about the costs of this storage at the [Pricing](https://cloud.google.com/firestore/enterprise/pricing) page.\n\nString size\n-----------\n\nString sizes are calculated as the number of [UTF-8 encoded](https://en.wikipedia.org/wiki/UTF-8) bytes + 1.\n\nThe following are stored as strings:\n\n- Collection name\n- Field names\n- String field values (including `_id`)\n\nFor example:\n\n- The collection name `tasks` uses 5 bytes + 1 byte, for a total of 6 bytes.\n- The field name `description` uses 11 bytes + 1 byte, for a total of 12 bytes.\n\nField value size\n----------------\n\nThe following table shows the size of field values by type.\n\nFor example, a boolean field named `done` would use 6 bytes:\n\n- 5 bytes for the `done` field name\n- 1 byte for the boolean value\n\nDocument size\n-------------\n\nThe size of a document is the sum of:\n\n- The [string size](#string-size) of the collection name\n- The sum of the [string size](#string-size) of each field name (except `_id`)\n- The sum of the size of each [field value](#field-size) (including `_id`)\n- 48 additional bytes\n\nThis example is for a document in collection `tasks`: \n\n {\n \"_id\": \"my_task_id\",\n \"type\": \"Personal\",\n \"done\": false,\n \"priority\": 1,\n \"description\": \"Learn Cloud Firestore\"\n }\n\nThe total size of the fields is 78 bytes:\n\nSo the document size is 6 + 78 + 48 = 132 bytes:\n\n- 6 for the collection name\n- 78 bytes for the fields\n- 48 additional bytes\n\nIndex entry size\n----------------\n\nThe size of an index entry in an index is the sum of:\n\n- The [string size](#string-size) of the collection name\n- The size of the `_id` field value\n- The sum of the indexed [field values](#field-size)\n- 48 additional bytes\n\nConsider a document in the `tasks` collection: \n\n {\n \"_id\": \"my_task_id\",\n \"type\": \"Personal\",\n \"done\": false,\n \"priority\": 1,\n \"description\": \"Learn Cloud Firestore\"\n }\n\nFor an index on the `done` and\n`priority` fields (both ascending), the total size of the index entry in this\nindex is 70 bytes:\n\n- 6 bytes for the collection name `tasks`\n- 11 bytes for the `_id` field value\n- 1 byte for the boolean field value\n- 4 bytes for the 32-bit integer field value\n- 48 additional bytes\n\nFor sparse indexes, if a document doesn't include any of the fields,\nthen no index entry is created. If a document contains at least one of the\nindexed fields, an index entry is created with absent indexed fields\nset to `NULL`.\n\nWhat's next\n-----------\n\nLearn about [pricing](https://cloud.google.com/firestore/enterprise/pricing)."]]