For my android app, I'm trying to match users based on (for now) location, age, and gender. I'm using GeoFire to query the Firebase Database for all users in a specified area.
I'm trying to figure out what the quickest/best way would be to filter the queried users based on the aforementioned criteria.
My first idea was to query the list of users that are currently searching for other users, where user nodes are structured like so:
I fear this implementation will be fairly slow, seeing as GeoFire will have to load the added children of age_range and gender. Additionally, this implementation does not adhere to the GeoFire guidelines, which specify that data and location should be seperated in the db.
My second idea was to structure the db like this (JSON format instead of screenshot)
-queue_locations
-uid
-g
-l
-lat
-lon
-queue_users
-uid
-age_range
-gender
Though this structure does adhere to GeoFire guidelines, it seems like a slow solution. I would have to query the db twice; one query returning the eligible users based on location, and another query returning eligible users' specified criteria.
My last solution is incredibly hacky, but seems like it would be very quick:
In this implementation, I've included the criteria in the key that GeoFire ties to the location. I will only have to query the database once with this solution, and i'll be able to see which users are eligible for matching extremely quickly.
Which of these solutions would be you argue is the best in terms of performance?
Thanks in advance.