7

This may sound silly but I'm a little bit confused with Firestore pricing.

I've read other questions here, read the doc and watched a few videos.

What does count as a read operation?

.get() or .data();

I tried figuring out myself by viewing the quota using and playing with Postman, but the read operation count is not increasing.

I'm using Node SDK.

Thanks

Faheem
  • 1,007
  • 10
  • 26

1 Answers1

9

From the offical documentation regarding listening to query results:

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.

The act of listening does not itself count as a read, however there is a minimum of one document charged per query. From the pricing page, under "Minimum charge for queries":

There is a minimum charge of one document read for each query that you perform, even if the query returns no results.

If you are about to call .data() it means that the document that you are looking for exist in the database and you are already inside the callback. With other words, the .get() call was already performed and you are already charged with a read operation.

Please also note that, if you re-listen a short while after you've already done so, you won't get charged for documents that haven't changed since you listened last.

Alex Mamo
  • 112,184
  • 14
  • 139
  • 167
  • 1
    In that case, if I've used a query, such as ".where().limit(10).get()", I've already been charged for 10 docs. – Faheem Oct 29 '18 at 12:50
  • 1
    Yes, that's correct. You are charged with only 10 read operations because you have used `limit(10)` method. – Alex Mamo Oct 30 '18 at 02:49
  • If am getting the total number of count from a collection, will that be considered as read operation? @AlexMamo – Mac_Play Apr 22 '19 at 07:21
  • Regarding counting documents, please check **[this](https://stackoverflow.com/questions/48534676/how-to-count-the-number-of-documents-under-a-collection-in-firestore/48540276#48540276)** out. – Alex Mamo Apr 22 '19 at 07:23
  • Thanks for the link. But that's for java, am looking for swift. Please help. @AlexMamo – Mac_Play Apr 22 '19 at 08:19
  • But a .data() counts as another read? Or it's just the .get()? Because I use a .get() and inside that I get many .data()'s – Dor Furman Nov 29 '21 at 19:48
  • 1
    @DorFurman When you call .data(), it means that want to read the result, so you'll be charged. – Alex Mamo Nov 30 '21 at 06:05