Firebase Realtime Database是否可以有效地遍历数十亿条帖子并由发布它们的用户检索它们? [英] Can Firebase Realtime Database effectively loop through billions of posts and retrieve them by the users that posted them?

查看:72
本文介绍了Firebase Realtime Database是否可以有效地遍历数十亿条帖子并由发布它们的用户检索它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Firebase实时数据库开发iOS应用。该应用程序可能包含数十亿个帖子,其中包含大量图像和数据,这些图像和数据需要根据特定用户的关注对象(如Instagram)进行检索。

I am developing an iOS app with Firebase Realtime Database. The app will potentially have billions of posts with a number of images and data that needs to be retrieved based on the people a specific user follows (something like Instagram).

I了解Firebase的最佳实践是将数据结构尽可能扁平化,这意味着拥有一个可能包含数十亿个条目的 Posts节点,然后我将使用 posted_by参数进行过滤。这有两个问题:

I understand that the best practice in Firebase is to structure data as flat as possible which would mean having a "Posts" node with potentially billion of entries, which I would then filter by a kind of 'posted_by' parameter. This begs two questions:

1)我能否通过查询返回所关注的任何用户的帖子来检索所说的帖子? (通过传递我关注的用户数组之类的信息)

1) Will I be able to retrieve said posts with a query that returns posts by any of the users I follow? (By passing something like an array of the users I follow)

2)Firebase是否足够有效,可以遍历潜在的数十亿条帖子,以查找符合我的条件的帖子,还是有其他更好的方法来构造数据以使应用程序尽可能地最佳?

2) Will Firebase be effective enough to loop through potentially billions of posts to find the ones that match my criteria, or is there otherwise a better way to structure data so as to make the app as optimal as possible?

请先感谢您的回答。

推荐答案

数十亿个条目都没有问题。
如果您有大量数据,则应检查Firebase是否是最具成本效益的解决方案。

Billions of entries are no problem. You should check if Firebase is the most cost efficient solution if you have huge volume of data.

1)Firebase可以做到这一点,但您可能不会这样做t希望用户等待所有条目(当单个用户有 lot 时),而是要求他们逐页地逐页请求,并且仅当用户滚动时才按需请求更多页面

1) Firebase can do that, but you probably don't want the user to wait for all entries (when there are a lot for a single user), but instead request them "page" by "page" and only request more pages on demand when the user scrolls up/down.

2)如果您确保在用户ID上有一个索引,则不必分别遍历每个索引。按索引搜索非常有效。

2) If you ensure you have an index on the user id, then it doesn't have to go through each one individually. Searching by index is efficient.

这篇关于Firebase Realtime Database是否可以有效地遍历数十亿条帖子并由发布它们的用户检索它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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