带查询的Firebase实时数据库定价 [英] Firebase Realtime Database Pricing with Query

查看:52
本文介绍了带查询的Firebase实时数据库定价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Firebase数据库的定价有疑问.我的数据库排行榜中大约有40万行,但是在我的应用中,我只想加载最后500行,所以我的问题是运行查询时加载的500行是否要收费?400,000行.

实时数据库每存储1 GB收费5美元,下载每GB 1收费.我用Firestore进行了计算,发现如果我为500行而不是400,000行收费,实时数据库会便宜得多.

我搜索了所有文档,但未找到有关查询的任何信息:

解决方案

您只需支付与查询结果相对应的 Firestore 文档数量(而不是集合中的文档数.

因此,在您的情况下,最多可以读取500次,因为您会将查询限制为500个文档.


另一方面,请注意,实时数据库查询并不是浅层的(而Firestore的查询是浅层的),因此,如果您查询JSON节点,您将该节点下的整个树.

I have a question about the firebase database pricing. I have about 400,000 rows in the leaderboard of my database, but in my app I just want to load the last 500 rows, so my question will I get charged for the 500 rows loaded when I run the query or will I get charged for all 400,000 rows.

Realtime database charges 5$ per gb stored and 1$ per gb downloaded. I did the calculation with Firestore and found that Realtime Database would be way cheaper if i get charged for the 500 rows and not the 400,000 rows.

I searched all documentation and have not found anything about queries: https://firebase.google.com/pricing https://firebase.google.com/docs/database/usage/billing

Can someone tell me if I get charged for just the 500 rows in my collection or for all the data in the collection and if there is a way to only get charged for the 500 rows maybe with security rules?

Here is my query code:

let queryRef = ref.child("Leaderboard").queryOrdered(byChild: "totalStars").queryLimited(toLast: 500)

How the database looks like. (It will have about 500,000 childs same as these and be loaded 200,000 per day, But I just want to be priced on the top 500 that I load and not the whole 500,000 each time a user loads the leaderboard is it possible?)

解决方案

You will only be charged for the number of Firestore Documents corresponding to the result of your query (not to the number of docs in the collection).

So in your case a maximum of 500 reads, since you would limit the Query to 500 documents.


On the other hand, note that the Realtime Database queries are not shallow (while the Firestore ones are) and therefore if you query for a JSON node you'll get the entire tree under this node.

这篇关于带查询的Firebase实时数据库定价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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