firebasegoogle-cloud-firestoregeofiregeohashinggeofirestore

GeoFire read ops efficiency


I'm using geofire to query Firestore as a user walks around. Here's my question:

Let's say my Firestore database has 5000 geohashed records in it and they're randomly located around the world. The records are all stored off a root node in the db. When I execute a geofire query with a very small radius, which of these is happening (assuming the default geofire params):

Option 1: the 1st geoquery generates 5000 billable firebase read ops as it searches all 5000 keys for matches. Each geoquery thereafter (from the same location or different location) uses a cached copy of the 5000 keys and does not generate billable read ops.

Option 2: every geoquery generates a new 5000 billable firebase read ops, regardless of whether the geoquery centerpoint or radius changes

Option 3: something else entirely!


Solution

  • The only billable reads that occur in Cloud Firestore are for those documents returned to the client. GeoFire doesn't change this fact. GeoFire just takes your requirements, translates that into a Firestore query that matches, at minimum, the number of documents that would fall into your requested radius, and possibly some extra. It does not consider all of the documents in the collection. That would be massively inefficient, and defeats the purpose of geohashes in the first place.

    From their documentation:

    GeoFire selectively loads only the data near certain locations, keeping your applications light and responsive, even with extremely large datasets.