If I'm subscribing to a collection that has 1000 docs, will I bee charged for 1000 reads as soon as the subscription is initiated? Per https://firebase.google.com/docs/firestore/pricing#listens I'd say no, but per https://stackoverflow.com/a/60356400/9118098 I'd say yes.
I'm asking as I have an "ever-growing" calendarEvents collections, and am trying do decide whether it'd be better to structure data as
calendarEvents/{calendarEventId}
or
calendarEvents/{2022}/March/{calendarEventId}
to keep the cost down, as the latter allows me to subscribe to the current month only.
CodePudding user response:
If by subscription you mean Firestore listeners then you are charged based on the number of document retrieved by the listener.
For example, your collection has 1000 documents and you add a listener on the whole collection then you'll be charged 1000 reads for those documents and 1 read for each subsequent update received. If you add some query clause such as where(field, "==", value)
and let's say this matched and returned only 700 documents, then you'll be charged 700 reads for initial read and 1 for each update received.