使用查询读取Firebase数据库带宽的使用情况 [英] Firebase database bandwidth usage when read with Query
问题描述
我只执行读取较低节点子节点,如最佳实践中所述,以节省带宽。
如果我执行这样的查询:
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屋!