如何计算Firestore查询/where操作上的读/写? [英] How to calculate read/writes on Firestore query/where operation?
问题描述
Firebase Firestore文档说:
The Firebase Firestore documentation says:
从集合中获取多个文档
您还可以检索通过查询一个文档中的一个请求来获取多个文档收藏.例如,您可以使用where()查询所有满足一定条件的文档,然后使用get()检索结果:
You can also retrieve multiple documents with one request by querying documents in a collection. For example, you can use where() to query for all of the documents that meet a certain condition, then use get() to retrieve the results:
var citiesRef = db.collection('cities');
var query = citiesRef.where('capital', '==', true).get()
.then(snapshot => {
snapshot.forEach(doc => {
console.log(doc.id, '=>', doc.data());
});
})
.catch(err => {
console.log('Error getting documents', err);
});
如果我有一个包含N个文档的馆藏,是否需要为上述查询支付N次阅读费用或单次阅读?
If I have a collection with N documents, would I incur a N-read fee or a single read, for the above query?
是否有任何方法可以使用SDK在每个调用的基础上检索读写计数?
Is there any way to retrieve the read/write count on a per call basis using the SDK?
作为我提出问题的合理背景,我有一个包含大量文档(大约20,000个)的单一馆藏.我想以最具成本效益的方式(最少的阅读)导出整个馆藏的文档.
As some background for my rational for asking, I have a single collection with a large number of documents (around 20,000). I want to export the entire collection's documents in the most cost efficient manner (least reads).
推荐答案
查询产生的每个文档都算作已读文档.如果您的查询匹配并返回N个文档,则将花费N个文档读取次数.
Every document yielded by a query counts as a document read. If your query matches and returns N documents, it will cost N document reads.
这篇关于如何计算Firestore查询/where操作上的读/写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!