4

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

2 Answers2

5

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

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • btw Frank note that everyone is trying to solve the same basic user registraiton problem: people want unique user readable user names (ie not just unique internal user ids) and unique emails... firebase reeally needs something like a 'unique' key word either specifically for user registraiton or just a general capability. i cannot count how manyu of those types of questions there have been... – Creos Jun 18 '16 at 03:25
  • Thank you! This makes a lot of sense. Hopefully I will reach enough users to switch to a non-query based model. – Helix Probe Jun 18 '16 at 15:49
1

Scalable or not is determined by your user.

Behind the scene Firebase library is just downloading JSON string and you know exactly what happen if the string is too long and the file size to be downloaded reach (for example 3MByte)

If your user is able and okay with 3MByte for a request, than you can go with it. But I don't if I am your user.

Edward Anthony
  • 3,354
  • 3
  • 25
  • 40