Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What counts as a read operation in Firestore?

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

like image 568
Faheem Avatar asked Oct 28 '18 12:10

Faheem


People also ask

What does reads mean in Firebase?

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.

How many reads can firestore handle?

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.

How do you reduce the number of read operations in cloud firestore?

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.

Why are my firestore reads so high?

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.


1 Answers

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.

like image 134
Alex Mamo Avatar answered Oct 21 '22 07:10

Alex Mamo