Madhavam Shahi
Madhavam Shahi

Reputation: 1192

Regarding firebase reads and writes

I have some questions regarding firebase, which I think many of the beginners have. Let's say I have this query:-

var collecRef=FirebaseFirestore.instance.collection('aCollection').where("a"=="b").orderBy(//some more code);

If I execute this, how many reads will it cost? If :-

  1. There are 5 documents which match the condition (a==b)

  2. There are no documents which match the condition.

Now,

if I want to update the data in a document using setData(), with merge=true, would it cost a write? If data is intact? For example in a document I have saved the user name of a user and in my app, my users can change their names.

Now, If they try to update their name with (setData()), and they haven't entered a DIFFERENT NAME(the name is same), would it cost a write?

Upvotes: 0

Views: 29

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317968

One document received from a query costs one read. That is all you need to know. The conditions don't matter, and the size of the collection doesn't matter. Just the number of documents received.

One call to setData costs one write. It doesn't matter what you write, or the current contents of the document.

Upvotes: 2

Related Questions