Deleted firestore data not reduce Stored Data Quota - firebase

Why when I deleted data from firestore, not reduce Firestore Stored Data Quota, I've tried to delete all data from CLI with this commad :
>firebase firestore:delete --all-collections
? You are about to delete YOUR ENTIRE DATABASE. Are you sure? Yes
Deleting the following collections: restaurants
Deleted 94 docs (26 docs/s)
Is there anything I miss regarding this quota problem?

After a few days I deleted all the data, today I see the quota has been reduced (reset to 0 GB), I'm not sure what I've missed, because there is no cycle information for the firestore stored data quota, considering that the firestore is still beta, I hope to get information related to the day later on
Thanks

firebase.database().ref('mynode/mychildnode').remove();

Related

Are we charged for failed Firestore transactions

If a transaction reads 3 docs and then updates 2 documents successfully but something after this causes the transaction to fail... will I be charged for the 3 reads and 2 writes that were made even though they are rolled back?
Edit---
Also will the get() below only cost 1 read? Where col2 is a subcollection of doc1.
db.collection('col1').doc('doc1').collection('col2').doc('doc2').get();
Edit 2
The firebase website states the following
For example, if a transaction reads documents and another client modifies any of those documents, Cloud Firestore retries the transaction. This feature ensures that the transaction runs on up-to-date and consistent data.
So say my transaction performs 10 reads on 10 different documents. If this gets called and during exectution some of the same documents are updated by other users, which will make the transaction retry, am I going to be hit with 10 * Number of retries for my reads?
Edit 3
I have read more about the transactions here https://firebase.google.com/docs/firestore/transaction-data-contention and it states that the server side transactions will lock the documents and wait for the transaction to finish.
q1) As the transaction is locking and not retrying over and over... will multiple concurrent calls to the firebase function that has a transaction not cost any extra reads/writes and will the functions just take longer to execute because of the lock?
q2) The webpage also has a banner at the bottom stating
Note: Only the server client libraries support transactions with read operations after write operations. For transactions in the mobile/web SDKs, document reads must come before document writes.
I just tried this on my firebase function and recieve the following error...
Error: Firestore transactions require all reads to be executed before all writes.
at Transaction.get (/srv/node_modules/#google-cloud/firestore/build/src/transaction.js:76:19)
I am using firebase admin version "^8.8.0", is performing reads after writes a feature that has been added in newer versions?
If transactions fail, will I still be charged?
Yes. A read was completed so you are charged for it. (I am unsure if there are any "rollback charges" - as the change now needs to be reversed.)
What is the cost of a sub-collection document read?
The doc1 was not read - so it would not be charged. You are charged for only one read.
I couldn't find a clear text in the documentation and these answers are from my personal usage for Firebase for over a couple years. A Firebasers confirmation would be helpful.

How many clients are connected to my firestore?

I am working on a flutter app that fetches 341 documents from the firestore, after 2 days of analysis I found out that my read requests are increasing too much. So I made a chart on the stackdriver metrics explorer from which I get to know that my app is just reading 341 docs a single time, it's the firebase console which is increasing my reads.
Now, comes to what are the questions that are bothering me,
1)How reads are considered when we see data on the console and how can I reduce my read requests? Basically there are 341 docs but it is showing more than 600 reads whenever I refresh my console.
2)As you can see in the picture there are two types of document reads 'LOOKUP' and 'QUERY', what's the exact difference between them?
3)I am getting data from the firestore with a single instance and when I open my app the chart shows 1 active client which is cool but in the next 5 minutes, the number of active clients starts to increase.
Can anybody please explain to me why this is happening?
For the last question, I tried to disable all the service accounts and then again opened my app but got the same thing again.
Firestore.instance.collection("Lectures").snapshots(includeMetadataChanges: true).listen((d){
print(d.metadata.isFromCache);//prints false everytime
print(d.documents.length);// 341
print(d.documentChanges.length);//341
});
This is the snippet I am using. When the app starts it runs only once.
I will try to answer your questions:
How reads are considered when we see data on the console and how can I
reduce my read requests? Basically there are 341 docs but it is
showing more than 600 reads whenever I refresh my console.
Reads are considered depending on your how you query your Firestore database in addition to your access to this database from the console so using of the Firebase console will incur reads and even if you leave the console open to do other stuff, when new changes to database occured these changes will incur reads also, automatically.and any document read from the server is going to be billed. It doesn't matter where the read came from. The console should be included in that.
Check this official documentation under the "Manage data" title you can see there is a note : "Note: Read, write, and delete operations performed in the console count towards your Cloud Firestore usage."
Saying that if you think there is an issue with this, you can contact Firebase support directly to have more detailed answers.
However, If you check the free plan of Firebase you can see that you have 50K free reads per day.
A workaround that I found for this (thanks to Dependar Sethi)
Bookmarking the Usage tab of the Firestore page. (So you basically
'Skip' the Data Tab)
Adding a dummy collection in a certain way that ensures it is the
first collection(alphabetically) which gets loaded by default on
the Firestore page.
you can find his full solution here.
Also, you can optimise your queries however you want to retreive only the data that you want using where() method and pagination with Firebase
As you can see in the picture there are two types of document reads
'LOOKUP' and 'QUERY', what's the exact difference between them?
I guess there are no important difference between them but "QUERY" is getting the actual data(when you call data() method) while "LOOKUP" is getting a reference of these data(without calling data() method).
I am getting data from the firestore with a single instance and when I
open my app the chart shows 1 active client which is cool but in the
next 5 minutes, the number of active clients starts to increase.
For this question, considering the metrics that you are choosing in Stackdriver I can see 3 connected clients. and as per the decription of "connected client" metric:
The number of active connections. Each mobile client will have one connection. Each listener in admin SDK will be one connection. Sampled every 60 seconds. After sampling, data is not visible for up to 240 seconds.
So please check: how many mobiles are connected to this instance and how many listeners do you have in your app. The sum of all of them is the actual number of connected clients that you are seeing in Stackdriver.

Error 402 - Firebase quota storage exceeded

Let me breakdown of what happened. Yesterday I tried to insert some videos from firebase realtime database to my app in the form of recyclerview and the first 2 testing with my physical device, it went fine but then during the third time testing, my app suddenly didn't work and when I checked what was going on, It said this."V/FA: Inactivity, disconnecting from the service" Then when I went into further analysis I soon came to realize it had this error as in the code.
{
"error": {
"code": 402,
"message": "Quota has been exceeded for this project. Please visit the Firebase pricing page to
learn more.",
"status": "ACCESS_BUCKET"
}
}
Im very sure that my storage is less than 100 mb but yet I got this result. However, today it's back working but I want to know what kind of action would invoke this error provided that I have ample of storage that is yet to be used.. Any help to clarify the issue that I went through would be much appreciated.. Thanks in advance
There are more quota than just the total size of the bucket. From the pricing page:
Storage
GB stored: 5 GB
GB downloaded: 1 GB/day
Upload operations: 20K/day
Download operations: 50K/day
Given your description you exceeded one of the daily limits, likely the bandwidth usage, which is 1 GB/day. That would also explain why it started working again on the next day.

Firebase console reads cost

Does using the firebase console and clicking on different collection/documents count against my read operations quota?
I have about 2 real users and about 13 fake ones and my usage is showing 1100 reads so far today. There are only about 30 documents in the entire database!
Any document read from the server is going to be billed. It doesn't matter where the read came from. The console should be included in that.

Cosmos DB giving 'Storage quota for 'Document' exceeded' for small documents

I'm encountering a problem where, the Azure Cosmos DB is giving Status Code: 403 Storage quota for 'Document' exceeded message for documents which are less than, 2 MB in size. I know, there is a limit on the document size but, in this case I tried with 5 KB document and it gave the same message. I'm using documentdb for storing JSON data.
According to
https://learn.microsoft.com/en-us/rest/api/documentdb/http-status-codes-for-documentdb
403 is also returned during a POST to create a resource when the resource quota has been reached. An example of this is when trying to add documents to a collection that has reached its provisioned storage.
I have encountered this when I have tried to push more data into a partition when its size has already reached 10 GB.

Resources