Why does merging the same document count against the write quota?

79 views
Skip to first unread message

Jason

unread,
Oct 24, 2018, 1:45:42 AM10/24/18
to Firebase Google Group
I just performed a test where I wrote documents to Firestore and then returned later to performed a set with SetOptions.merge. I did this test with a few thousand records to determine if merging the same record counts against the write quota. It appears that even though the records is exactly the same and the merge option is used that Firestore counts this as a write. Is this correct? Do set of the same data count against the write quota?


stuff
= firebase.getFirestore().collection("stuff");
stuff
.document(something.getThing()).set(something, SetOptions.merge());



I thought the local stuff reference would contain the existing documents in which case by calling set with the merge option would then merge to the local and not send to the cloud. I would think that down 
stream devices would not receive updates given the data has not changed. 

Also, on a smaller test I updated a singled document with the merge option set. I watched the document via the console and only the field where the value diffed flashed (the console flashes/blinks the 
field on change).

Thanks!
Jason

Ian Barber

unread,
Oct 28, 2018, 6:06:28 AM10/28/18
to fireba...@googlegroups.com
Hi Jason, 

Had a bit of a discussion about this internally. The reason its a write is that the client can't know whether there has been a change on the server. Merge is really about not touching fields which aren't specified, but it still has to be sent to the server.

Ian

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/164b18d6-228f-4847-a0c4-c50171595a70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages