14

I am a bit confused as to whether a query like the one below counts as one read or 25 reads for Firestore pricing ?

queryRef.limit(25).get().then(()=>{

...

});

I understand that in the pricing chart a "document read" has been defined as the unit but I am a bit confused about a query like above and need a confirmation.

TheBen
  • 3,410
  • 3
  • 26
  • 51

1 Answers1

24

If your query returns 1 document, you will be charged 1 read. If your query returns 25 documents, you will be charged 25 reads. A document does not have the be "read" to be omitted in a query, except in the case of using an offset to skip documents. According to the documentation:

There are no additional costs for using cursors, page tokens, and limits. In fact, these features can help you save money by reading only the documents that you actually need.

However, when you send a query that includes an offset, you are charged a read for each skipped document. For example, if your query uses an offset of 10, and the query returns 1 document, you are charged for 11 reads. Because of this additional cost, you should use cursors instead of offsets whenever possible.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • As you said @Doug Stevenson firestore charges on the basis of document reads let say i create a single document and then nest inside or pupulate it with heavy data will that be counted as a single read .As we can do multiple maps and list inside a single document so will it help to reduce writes. – UTKARSH Sharma Aug 08 '20 at 09:45