1

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.

Jacobo Koenig
  • 11,728
  • 9
  • 40
  • 75

1 Answers1

0

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.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567