Firebase:Cloud Firestore:listDocuments:doc读取成本1还是N?可以使用分布式计数器吗? [英] Firebase: Cloud Firestore: listDocuments: doc read cost 1 or N? Possible alternative to Distributed Counter?

查看:70
本文介绍了Firebase:Cloud Firestore:listDocuments:doc读取成本1还是N?可以使用分布式计数器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

构建社交媒体应用,并面对1write/doc/sec的限制.因此,将投票数据保留在后期文档中将无法正常工作.我已经读过"Distributed Counters",但是文档的读/写成本呈线性增长.我一直在探索可用的firebase函数,并对"listDocuments()"感兴趣,该函数返回DocumentReference的列表.

Building a social media app and confronting the 1write/doc/sec limit. Consequently, keeping vote data in the post document will not work at scale. I have read into "Distributed Counters", but the document read/write cost scales linearly. I have been exploring the firebase functions available and am interested in "listDocuments()", which return a List of DocumentReference's

不幸的是,翻阅文档我无法确定listDocument的读取成本是集合中的1还是1/doc.

Unfortunately, digging through the documentation I cannot determine if listDocument read cost is 1 or 1/doc in the collection.

我的计划是每个帖子有两个子集合,vote1/vote2.这消除了大规模的写瓶颈.为了获取投票计数,我想在每个子集合上使用listDocuments()的长度.

My plan is to have two subcollections per post, vote1/vote2. This removes the write bottleneck at scale. To retrieve the vote count I would like to use the length of listDocuments() on each subcollection.

我知道firebase有一些巧妙的索引技巧,但是我也很好奇这对数据库的效率不高.即用户在检索计数时会注意到延迟吗?

I know firebase has some neat indexing tricks, but I am also curious if this is an inefficient operation on the database. i.e. will the user notice a delay when retrieving the counts?

推荐答案

不幸的是,翻阅文档我无法确定listDocument的读取成本是集合中的1还是1/doc.

Unfortunately, digging through the documentation I cannot determine if listDocument read cost is 1 or 1/doc in the collection.

调用 listDocuments API会花费一个读取的文件,返回的每个文件.

Calling the listDocuments API cost one document read per document that is returned by it.

这篇关于Firebase:Cloud Firestore:listDocuments:doc读取成本1还是N?可以使用分布式计数器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆