Can Firebase Realtime Database effectively loop through billions of posts and retrieve them by the users that posted them?

纵饮孤独 提交于 2020-01-22 02:00:42

问题


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 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) 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) 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?

Thanks in advance for the answers.


回答1:


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 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) 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.



来源:https://stackoverflow.com/questions/46329375/can-firebase-realtime-database-effectively-loop-through-billions-of-posts-and-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!