Helix Probe Helix Probe - 5 months ago 18
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

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:

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