Bielik
Bielik

Reputation: 992

Cloud Firestore: How is read calculated?

In Cloud Firestore we are charged for read/write/delete operations. Perhaps this is obvious for some but I could not find anywhere what is considered read. If I have a collection of 10 records and I fetch them all in form of a list, does it count as 10 reads or 1 (since I read only once from the database)?

Upvotes: 33

Views: 20015

Answers (3)

Frank van Puffelen
Frank van Puffelen

Reputation: 598708

Since you're reading 10 documents, so you'll be charged for 10 document reads. The number of read API calls you use is not relevant here.

Also see:

Not the same use-case, but I also experimented with measuring document reads on the server that you can read about here: Counting document reads per user in Firestore

Upvotes: 44

Harsh Kothari
Harsh Kothari

Reputation: 512

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. Generally, this number is low during the development phase but when your documents are excessive then it would create a problem for you as it will increase your read if you simply open your console.

to solve this problem either you may prefer to create a separate admin panel which you can fetch the required document instead of getting read the whole documents in firestore console or just create an collection named a or A with an empty document so that whenever you load firestore console, only documents in the a or A collection are loaded.

NOTE: you should only create a empty document collection named either a or A so that whenever you open your console that collection would be opened in default instead of other document.

Upvotes: 6

emalamisura
emalamisura

Reputation: 2894

I did a bunch of testing of this and can confirm that the Firebase Database tab uses an insane amount of reads. For me it incurred a 600+ read count every single time I opened it. If I clicked off that tab and back onto it, I would get another 600+ hit on read count. I monitored the usage of this using the GCP Usage for Firestore so I could avoid having that window open.

This is an absurd cost, it has taken me into 100k+ reads by scrolling through it without realizing what was happening. You could even hit a million pretty easy if you were spending a lot of time in there doing something.

In addition, if you leave that tab open as you make calls, it throws your numbers WAY WAY off as it also shows real time updates.

Be very careful when and how you use these tools. Personally I don't think it makes sense to incur usage costs for using internal tools. Especially since they don't even tell you these tools will incur usage costs.

Upvotes: 37

Related Questions