1

I couldn't find any information for this specific scenario: Say I have a these documents in a collection:

doc_1
doc_2
doc_3

Now, I run two queries. The first query returns doc_1 and doc_2. The second query returns doc_2 and doc_3. So doc_2 is returned twice in two separate queries. Will Firebase charge me 3 or 4 total reads (-> Will the twice-returned document be counted as one or two reads)?

jbxbergdev
  • 860
  • 1
  • 10
  • 23

1 Answers1

0

The number of reads depends of number of documents returned by particular query. In the use case you have 2 queries, both are returning 2 documents so it gives us 4 total reads.

I think this is quite well explained in Firebase documentation. You can check few other SO questions about it like: here, here nd here (add I think you can dig more).

vitooh
  • 4,132
  • 1
  • 5
  • 16
  • @WytrzymałyWiktor I'm not sure. The documentation which vitooh cites as a source is not entirely clear on what happens if the same document(s) appear(s) in multiple queries: "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.". You _could_ read into this that charges are based on individual queries, however the documentation is not quite clear / doesn't go enough into detail IMO. – jbxbergdev Mar 10 '21 at 13:06
  • @jbxbergdev you can always test it. Just create testing project write a code and run it once. In Firebase console in Firestore you will see reads in "Usage". Please as well watch the video from the documentation (https://youtu.be/6NegFl9p_sE?t=89) I am not sure what more to add. – vitooh Mar 10 '21 at 14:36