[[["易于理解","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-18。"],[],[],null,["# Pricing examples\n================\n\nThis page includes examples of how billing units are calculated in\nsome of the most common scenarios. Note that each query might differ in data\nprocessed based on factors such as the query plan, the shape of the data,\nand the indexes available.\n\nWe recommend using the [Query Explain](/firestore/mongodb-compatibility/docs/query-explain) feature to better\nunderstand the cost and performance of your specific queries.\n\nRead operations\n---------------\n\nMost read operations entail either performing a point read of a specific\ndocument or scanning a rage of data based on an identifier.\nRead operations consume read units. Read units are calculated in 4 KiB tranches. See the following examples.\n\n### Point reads\n\nExample billing for point reads:\n\n- Point read of a single 1 KiB document. Consumes: 1 read unit\n- Point read of a single 4 KiB document. Consumes: 1 read unit\n- Point read of a single 1 MiB document. Consumes: 256 read units\n- Point read of 100 documents, 1 KiB each. Consumes: 100 read units\n\n### Scanning\n\nThe following examples include scenarios that scan documents or index entries.\n\n#### Scanning Documents\n\n- Query which scans 100 documents, 1 KiB each. Consumes: 25 read units\n\n#### Scanning indexes\n\nThe scanning cost, in terms of bytes, is the same regardless of whether it is a\ndocument or index being scanned. However, index entries are often smaller\nin size. As a result, they can often provide a more cost effective way of scanning data.\n\n- Query which scans 100 index entries, 1 KiB each. Consumes: 25 read units.\n- Query which scans 100 index entries, 128 bytes each. Consumes: 4 read units.\n\n### Minimum document or index entry size\n\nIn certain situations it may not be necessary to read the contents of a\ndocument or index entry to satisfy a query. This includes simple count queries\nlike counting the total number of documents in a collection.\nIn these situations, a minimum cost of 32 bytes applies per item scanned.\n\n- Count the number of documents in a collection. The query scans 1000 items in the collection. Consumes: 8 read units.\n\n### Combination of scanning and point reads\n\nMany queries perform a combination of scanning and point reads to satisfy an\noperation.\n\n- Query which scans 128 index entries, 256 bytes each and performs a point read of 128 documents, 4 KiB each. Consumes: 136 read units, comprised of:\n - 128 read units for point reads\n - 8 read units for index scans\n\n### Query Explain\n\n[Query Explain](/firestore/mongodb-compatibility/docs/query-explain) helps you understand how the database\nexecutes your queries. The details provided can help you optimize your\nqueries.\n\nThe following costs apply when using Query Explain:\n\n- Query Explain which executes the query: Query cost applies.\n- Query Explain using plan only option. Consumes: 1 read unit (minimum cost of a query)\n\nWrite operations\n----------------\n\nWrite operations (creates, updates and deletes) are charged based on the\nsize of the documents and indexes being created, modified, or deleted during the\noperation. Write operations consume write units. Write units are calculated in 1\nKiB tranches.\n\nSimple write operations, like update by document ID, only incur the cost of the writes.\nWrite operations which require querying to satisfy the operation will\nadditionally incur the read costs associated with the query.\n\nSee the following examples.\n\n### Creates\n\n- Create a new 10 KiB document with no indexes. Consumes: 10 write units\n- Create a 1 KiB document with 1 index entry of 256 bytes on the collection. Consumes: 2 write units\n\n### Updates\n\n- Find a 10 KiB document by document ID and update with no indexes on the collection. Consumes: 10 write units\n- Find a 1 KiB document by document ID and update 1 field with 1 index entry of 256 bytes. Consumes: 3 write units. Note: Updating an index entry in this situation consumes 2 write units -- one to delete and one to recreate the index entry.\n- Find a 1 KiB document by document ID and update nothing (no changes). Consumes: 1 write units (the minimum write costs)\n- Query all 1 KiB documents in a collection, which scans 1,000 documents, and insert a new 256 bytes field with no indexes on the collection: 1000 read units and 1000 writes units.\n\n### Deletes\n\n- Delete a 1 KiB document, which has 1 index on the collection. Consumes: 2 write units\n- Delete a 1 KiB document, which has no indexes on the collection. Consumes: 1 write unit\n\nIndex builds\n------------\n\nIndex builds charge for the index entries created or modified during the build\noperation. These costs are incurred anytime an index definition is added or\nremoved. The index entries are billed identically to writes incurring 1 write\nunit per 1KiB.\n\n- Create a new index for a collection containing 500 documents, index entries created are 1 KiB each. Consumes 500 write units.\n- Delete an existing index for a collection containing 500 documents, index entries deleted are 1KiB each. Consumes 500 write units."]]