firebase / geofire-java

GeoFire for Java - Realtime location queries with Firebase
MIT License
670 stars 271 forks source link

What is the Pricing logic for Geo Queries? #162

Closed aytunch closed 4 years ago

aytunch commented 4 years ago

Let's say I have 100,000 locations saved in the DB. And I make a radius query which returns 5 locations. Will I be charged for 100,000 document reads or 5? In the background do we download the unused results too?

Also while listening to a query result in real time, If a location changes which is out of bounds of my query, does that still count as a read?

samtstern commented 4 years ago

@aytunch this question has a few answers:

  1. This library is only for Realtime Database, not Cloud Firestore, so you're not charged per document read. You're charged for network traffic and storage.
  2. GeoFire uses the Geohash system to index locations. So it's not possible for me to say exactly, but the answer is much closer to 5 than 100,000. We do as much server-side filtering as possible using the GeoHash and then do the final filtering on the client.
  3. For real-time results the answer is the same. If something far away changes that won't affect your query. If something nearby changes it could fall within the geohash accuracy window even if it's not a true match.