有关实时数据库中数据传输的一般问题 [英] General questions about data transfer in Realtime Database

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

问题描述

当我说转移"时,我指的是可计费的转移数据,我相信这只是下载的数据.

假设您正在监听ref('/posts/').onValue(),然后调用ref('/posts').once(),由于客户端已经拥有最新版本的数据,因此Realtime Database是否知道不通过网络传输任何数据? /p>

现在,假设您正在收听ref('/posts/').onValue(),并且发现了新的更新.实时数据库是否传输增量或整个文档?

现在可以说您正在做类似ref('/posts/').orderByChild('timestamp').limitToLast(10)的过滤器,并且您的/posts/引用有500个条目.实时数据库会将10个孩子转移到客户端还是全部500个孩子?

现在可以说您在Realtime Database中注册了数千个侦听器,您是否需要为设置和删除侦听器付费?

注意:我不确定这是否应该是多个问题,或者是否不应该将其发布在Stack Overflow上.这就是堆栈新手的不确定性.

解决方案

如果您同时将多个侦听器附加到一个位置,则该位置的数据将仅传输一次.

当您要监听的较大节点的一部分进行更新时,Firebase会尝试仅通过网络发送增量.确切数据的大小取决于节点的总大小及其下的更新.

如果查询的属性上有索引,则仅传输查询结果.如果您在该属性上没有索引,则Firebase客户端将记录错误,在该位置传输所有数据并过滤客户端.

请注意,有一些工具可以了解这些内容:

  1. 使用 Firebase数据库分析器了解有关读/写速度的更多信息,带宽和未编制索引的查询.
  2. Lets say you're listening to ref('/posts/').onValue() and then you call ref('/posts').once(), does Realtime Database know to transfer no data across the network because the client already has the most up-to-date version of the data?

    Now lets say you're listening to ref('/posts/').onValue() and a new update is found. Does Realtime Database transfer the delta or the entire document?

    Now lets say you are doing a filter like ref('/posts/').orderByChild('timestamp').limitToLast(10) and your /posts/ ref has 500 entries. Does Realtime Database transfer 10 children to the client or all 500?

    Now lets say you register thousands of listeners with Realtime Database, are you billed for the setting and removal of listeners?

    Note: I'm not sure if this should be multiple questions or if this shouldn't be posted on Stack Overflow. Such is the uncertainty of a stack newbie.

    解决方案

    If you attach multiple listeners to a location at the same time, the data for that location will only be transferred once.

    When there is an update to a part of a larger node that you listen to, Firebase tries to send only the delta over the wire. The size of the exact data depends on the total size of the node and the update under it.

    If you have an index on the queried property, only the query results will be transferred. If you don't have an index on the property, the Firebase client will log an error, transfer all data at the location and filter client-side.

    Note that there are tools to learn about these things:

    1. Use the Firebase Database profiler to learn more about read/write speed, bandwidth, and unindexed queries.
    2. Enable debug logging or check the network tab of your browser to see the exact wire traffic between the client and the database.

    这篇关于有关实时数据库中数据传输的一般问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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