johnstontrav
johnstontrav

Reputation: 339

which method will yield better performance?

Consider an example data structure with nested items. ie: schools.classes.students

In the UI is used to add/edit/delete the students only.

Do I connect the firebase Ref at the root (schools) or classes and get the UI to iterate over and manage the the data or does each student have a dataRef as this is where the data will be changed?

If each student has its own Firebase Ref (lets say 100 students), does this add any performace/latency issues?

I can explain further if needed but wanted to keep post short.

Upvotes: 1

Views: 153

Answers (1)

Andrew Lee
Andrew Lee

Reputation: 10195

Firebase is intended to be used with large numbers of references and callbacks. Creating a reference ("new Firebase(...)") is an extremely lightweight option, so you should feel comfortable doing this very often.

In your app, usually rendering and network activity are the major bottlenecks, so loading and re-rendering large chunks is likely to be slow. I'd recommend accessing Firebase in a very granular way, and tying it tightly to your GUI so that only the minimum set of GUI elements need to be re-rendered when things change.

If this wasn't clear, please provide some example code and I can make some additional recommendations.

[I work at Firebase]

Upvotes: 1

Related Questions