Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

firestore snapshotlistener costs

can anybody specify the costs for me in the following scenario:

When a query with a snapshotlistener listens to a collection and one document of the collection will be added or updated, will I be charged for the document that was updated or for all documents in the query?

Example: I have a snapshotlistener on a user collection with a where statement that shows me 20 entries. Now one document in that query will be changed, will I be charged for all 20 documents, because the snapshotlistener returns 20 documents or only for the one that changed?

Thank you!

like image 769
peterpeterson Avatar asked Dec 02 '17 01:12

peterpeterson


People also ask

Is Google firestore expensive?

Cloud Firestore includes a no-cost tier to help you get started at no cost. After you exceed the usage and storage quotas for the no-cost tier, you're charged for the database operations you perform, the data you store, and the network bandwidth you use.

How can I reduce firestore costs?

We can reduce the cost by a lot by using Firebase cloud functions. I love Cloud Firestore triggers! This does your job so smoothly and makes your app/website a lot faster.

Is firestore storage free?

Firestore offers free quota that allows you to get started at no cost. The free quota amounts are listed below. If you need more quota, you must enable billing for your Cloud Platform project.

Is firestore key-value store?

Cloud Firestore is a NoSQL database that stores data in documents, arranged into collections. Firestore is optimized for such collections of small documents. Each of these documents includes a set of key-value pairs.


3 Answers

Your snapshot listener will fire immediately with the 20 documents that match your query, and subsequently when the document changes.

You will be charged for 21 document reads in this case: the 20 reads for the initial snapshots and then the 1 read for the modified doc.

like image 109
Frank van Puffelen Avatar answered Oct 29 '22 15:10

Frank van Puffelen


You'll be charged for one read for the changed document.

Frank's answer is correct in that the first time you activate your listener, you'll automatically fetch down all 20 documents, but each subsequent document change will only result in one read.

like image 35
Todd Kerpelman Avatar answered Oct 29 '22 14:10

Todd Kerpelman


The snapshot listener will fetch all the collection's documents every time you start the activity or the load the fragment. But if something changed in the document while you using the app only one document will get fetched again. So maybe the best way to maintain you budget is using the mvvm pattern with depnding on cach in not important aspects

like image 20
mohammed msgm Avatar answered Oct 29 '22 16:10

mohammed msgm