I am developing an app using Firestore as a database and am a bit confused about firestore reads, I ma how does it count 1 read?
1. If whenever I call any document from the collection, does this document read cost me as 1 read? note: the document has 10 string fields with data so does it cost me 1 read? (document read) or 10 read? because am calling 10 fields of that document as well.
2. if document call doesn't consider as 1 read, then in the second stage am calling 10 string fileds of a document as well, so now does it consider as 10 reads?
if (value.contains("full_name")) {Bollen FullName = true;}
Note: In this stage, I am calling string field like this, which means if the field exists in the document then that's it I continue my next task. (Make sure that I haven't used stFullName = value.getString("full_name"); here, just checked that does field exists here or not?) So does it cost me as 1 read per 1 field, in total 10 reads?
3. Here I have the 3rd stage, where I am calling document with its 10 string field with 1 additional thing
if (value.contains("full_name")) {String stFullNameX = value.getString("full_name");}
Now here I am getting the string data from the field as well this time, does this 1 call per string field will be considered as 1 read? and calling 10 string field data value.getString in the string will cost me 10 reads?
CodePudding user response:
If you check the Firebase pricing page it says that Firestore charges for document reads (emphasis mine). So it charges your project each time it has to retrieve a document from/on the server.
If you load a document (so call get()
on a DocumentReference
to get a DocumentSnapshot
), that counts as one document read regardless of home many fields there are in the document. The number of fields does affect the size of the document though, so the bandwidth charges will be depend on the number of fields and the size of the data in there.
There is no charge for accessing a field in the DocumentSnapshot
. So once you have the DocumentSnapshot
, it doesn't matter how often you access the fields in there.
If you load a document multiple times with that same API, you will be charged one document read for each time you load the document.