This may sound silly but I'm a little bit confused with Firestore pricing.
I've read other questions here, read the doc and watched a few videos.
What does count as a read operation?
.get() or .data();
I tried figuring out myself by viewing the quota using and playing with Postman, but the read operation count is not increasing.
I'm using Node SDK.
Thanks
In Firebase firestore, read is counted in 2 ways, Here 1 document = 1 read. Firstly from your app where your client fetches the data from document you created in firestore and. Secondly You're charged for reads in the console too.
10 for single-document requests and query requests. 20 for multi-document reads, transactions, and batched writes. The previous limit of 10 also applies to each operation.
This means that Cloud Firestore will try to retrieve an up-to-date (server-retrieved) snapshot, but fall back to returning cached data if the server can't be reached. This is how we can reduce the number of reads in Cloud Firestore, by forcing the SDK to use only the offline cache and get the data only upon request.
Well, the answer is quite simple. In order to provide up-to-date data, the Firestore SDK needs to check the online version of the documents against the cached one. That's the reason why we are charged with new 50 reads, regardless of what exists in the cache or if something is changed or not on the server.
From the offical documentation regarding listening to query results:
When you listen to the results of a query, you are charged for a read each time a document in the result set is added or updated.
The act of listening does not itself count as a read, however there is a minimum of one document charged per query. From the pricing page, under "Minimum charge for queries":
There is a minimum charge of one document read for each query that you perform, even if the query returns no results.
If you are about to call .data()
it means that the document that you are looking for exist in the database and you are already inside the callback. With other words, the .get()
call was already performed and you are already charged with a read operation.
Please also note that, if you re-listen a short while after you've already done so, you won't get charged for documents that haven't changed since you listened last.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With