简体   繁体   English

Firebase FireStore 读取计数如何工作? 它会在文档上中继吗? 或文档字段? 文档字段数据?

[英]How does Firebase FireStore Read Count works? Does it relay on Document? or Document Field? of Document Field Data?

I am developing an app using Firestore as a database and am a bit confused about firestore reads, I ma how does it count 1 read?我正在开发一个使用 Firestore 作为数据库的应用程序,并且对 Firestore 读取有点困惑,我知道它是如何计算 1 读取的?

1. If whenever I call any document from the collection, does this document read cost me as 1 read? 1.如果每当我调用集合中的任何文档时,阅读此文档是否会花费我阅读 1 次? note: the document has 10 string fields with data so does it cost me 1 read?注意:该文档有 10 个包含数据的字符串字段,所以我需要阅读 1 次吗? (document read) or 10 read? (文件阅读)还是10阅读? because am calling 10 fields of that document as well.因为我也调用了该文档的 10 个字段。

2. if document call doesn't consider as 1 read, then in the second stage am calling 10 string fileds of a document as well, so now does it consider as 10 reads? 2.如果文档调用不考虑为1次读取,那么在第二阶段我也调用了10个文档的字符串字段,那么现在它是否考虑为10次读取?

if (value.contains("full_name")) {Bollen FullName = true;}

Note: In this stage, I am calling string field like this, which means if the field exists in the document then that's it I continue my next task.注意:在这个阶段,我像这样调用字符串字段,这意味着如果该字段存在于文档中,那就是它,我继续我的下一个任务。 (Make sure that I haven't used stFullName = value.getString("full_name"); here, just checked that does field exists here or not?) So does it cost me as 1 read per 1 field, in total 10 reads? (确保我没有使用stFullName = value.getString("full_name");在这里,只是检查了这里是否存在字段?)那么我是否需要花费我每 1 个字段读取 1 次,总共 10 次读取?

3. Here I have the 3rd stage, where I am calling document with its 10 string field with 1 additional thing 3.这里是第三阶段,我用它的 10 个字符串字段和 1 个额外的东西调用文档

if (value.contains("full_name")) {String stFullNameX = value.getString("full_name");}

Now here I am getting the string data from the field as well this time, does this 1 call per string field will be considered as 1 read?现在,我这次也从字段中获取字符串数据,每个字符串字段的 1 次调用是否会被视为 1 次读取? and calling 10 string field data value.getString in the string will cost me 10 reads?并在字符串中调用 10 个字符串字段数据value.getString将花费我 10 次读取?

If you check the Firebase pricing page it says that Firestore charges for document reads (emphasis mine).如果您查看 Firebase定价页面,它会显示 Firestore 对文档读取收费(强调我的)。 So it charges your project each time it has to retrieve a document from/on the server.因此,每次它必须从/在服务器上检索文档时,它都会向您的项目收费。

If you load a document (so call get() on a DocumentReference to get a DocumentSnapshot ), that counts as one document read regardless of home many fields there are in the document.如果您 加载文档(因此在DocumentReference上调用get()以获取DocumentSnapshot ),则无论文档中有多少字段,这都算作一个文档读取。 The number of fields does affect the size of the document though, so the bandwidth charges will be depend on the number of fields and the size of the data in there.但是,字段的数量确实会影响文档的大小,因此带宽费用将取决于字段的数量和其中的数据大小。

There is no charge for accessing a field in the DocumentSnapshot .访问DocumentSnapshot中的字段是免费的。 So once you have the DocumentSnapshot , it doesn't matter how often you access the fields in there.因此,一旦您拥有DocumentSnapshot ,您访问其中的字段的频率就无关紧要了。

If you load a document multiple times with that same API, you will be charged one document read for each time you load the document.如果您使用同一个 API 多次 加载文档,则每次加载文档都会向您收取阅读一份文档的费用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM