Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore read/write pricing; does .limit(25) counts as 25 reads or one?

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.

like image 369
TheeBen Avatar asked Jan 26 '18 02:01

TheeBen


1 Answers

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.

like image 196
Doug Stevenson Avatar answered Sep 19 '22 11:09

Doug Stevenson