使用查询读取Firebase数据库带宽的使用情况 [英] Firebase database bandwidth usage when read with Query

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

问题描述

我在我的android应用中使用了Firebase,我注意到这个应用使用了很多带宽。
我只执行读取较低节点子节点,如最佳实践中所述,以节省带宽。

如果我执行这样的查询:

  Query queryRef = firebaseRef.orderByChild(internalKey)。equalTo(false); 
queryRef.addListenerForSingleValueEvent(new ValueEventListener()
{
...



在数据库中,带宽的使用是统计所有的子节点还是只有那些有internalKey = false的?

解决方案

上传和下载的数据量,其实非常简单。



如果您有 internalKey 上定义了一个索引,那么Firebase将过滤其服务器上的数据只返回符合条件的元素。

然而,如果你在 internalKey 没有索引,所有的数据将被下载到客户端,然后客户端将进行过滤。您还应该在logcat iirc中看到一个警告。



当您看到大带宽用法,我建议启用调试日志记录( Fire base.getDefaultConfig().setLogLevel(Level.DEBUG))并检查logcat中的流量是否符合您的预期。


I'm using Firebase in my android app, and I've noticed that the app use a lot of bandwidth. I execute only read in the lower nodes childs like stated in the best practise to save bandwidth.

If I execute a query like this:

Query queryRef = firebaseRef.orderByChild("internalKey").equalTo(false);
queryRef.addListenerForSingleValueEvent(new ValueEventListener()
        {
           ...

In the database bandwidth usage are counted all the child node or only those with internalKey = false?

解决方案

The bandwidth counts the amount of data that you upload and download. It's really as simple as that.

If you have defined an index on internalKey, then Firebase will filter the data on its servers and return only the elements matching the condition.

However, if you don't have an index on internalKey, all the data will be downloaded to the client and the client will then do the filtering. You should also see a warning about that in logcat iirc.

When you see large bandwidth usage, I recommend enabling debug logging (Firebase.getDefaultConfig().setLogLevel(Level.DEBUG)) and checking if the traffic in logcat matches your expectation.

这篇关于使用查询读取Firebase数据库带宽的使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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