Helix Probe Helix Probe - 1 year ago 90
Swift Question

Are Firebase queries scalable

In my app to check for if an email (and username) is taken when signing up I use queries like this...

let emailRef = Firebase(url: "https://photocliq5622144.firebaseio.com/users")

emailRef.queryOrderedByChild("email").queryEqualToValue(email.text!.lowercaseString).observeEventType(.Value, withBlock: { email in

Would this work well with hundreds or even thousands of users (is this scalable)?

Answer Source

Hundreds: yes

Thousands: yes

Tens of thousands... probably (and congratulations on the success of your app)

Hundreds of thousands... you're likely better off with a non query-based data model. For example: if you want to access some data for the user by their email address, store a map from email address to uid:

    "HelixProbe@stackoverflow,com": "uid6479958"
    "puf@stackoverflow.com": "uid209103"

With such a simple list, you can read the user's data from their email address with two direct lookups, instead of one query (which will get slower as more and more items are added).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download