So when i read realtime data use onSnapshot in collection with 1000 document, i will pay for 1000 read for first time i render the page.
Nah my question is, when someone add 1 new document to that collection, am i get charged only for read 1 new document or i get charged again for read 1000 document 1 new document ?
I read some post on this site about that, and also i read from firebase website in link below but i not really understand.
https://firebase.google.com/docs/firestore/pricing#listens
This post
Listening to query results
Cloud Firestore allows you to listen to the results of a query and get realtime updates when the query results change.
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 are also charged for a read when a document is removed from the result set because the document has changed. (In contrast, when a document is deleted, you are not charged for a read.)
Also, if the listener is disconnected for more than 30 minutes (for example, if the user goes offline), you will be charged for reads as if you had issued a brand-new query.
CodePudding user response:
My question is: when someone adds 1 new document to that collection, am I get charged only for read 1 new document or I get charged again for read 1000 document 1 new document ?
The answer is to be found in the second block of the documentation excerpt you mention in your question:
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.
Listening to an entire collection is totally equivalent to listening to a query (the CollectionReference
class extends the Query
class), therefore when someone adds a new document to the collection, you are charged only for one document read.