Google-cloud-dotnet: Batch writes counts

Created on 3 Jul 2019  路  6Comments  路  Source: googleapis/google-cloud-dotnet

Environment details

  • OS: windows 10
  • .NET version: netcore2.1
  • Package name and version: Google.Cloud.Firestore 1.0.0-beta10

Bug report

when using writebatchs any operation like batch.Create or batch.Setcount as 2 write on firestore.

you can check with the debugger looking on the batch.Elements private field or just create a batch with 300 batch.Create or batch.Set and the 500 limit for request will be hit.

I dont know if this is the expected behavior anyway I think it could be really useful to have a public WriteCount property in the batch class

firestore p2 feature request

All 6 comments

I'll consult with the Firestore team on this. I suspect the details of the write are important here, as each write can end up as one or two elements depending on the content.
(I didn't think that the secondary writes counted against the limit, but I'm happy to be contradicted of course.)

I've spoken to the team, and yes, the additional writes do count - as do index updates. The latter makes it very hard / impossible to determine the number of writes that a batch will use, client-side. The advice from the team was that unless you're doing batches for atomicity, it would be better to just parallelize small writes instead of trying to "fill" the batch. I do understand that having a limit that you can't easily check for is frustrating, but given the index update aspect, I suspect that adding a WriteCount property to WriteBatch would actually make things worse rather than better :( I've suggested that the documentation should be updated with this advice too.

Please let me know if you'd like me to keep this issue open or close it.

Everything now is clear and I understand the complications.

There is no real solution to this issue and my problem is that i need to initialize firestore with a lot of data and batchwrites were convenient and fast

Also I agree with you about WriteCount

we can close this issue. it is enough to update the documentation

thanks for the quick and comprehensive reply

Right - it sounds like the team's suggestion is basically making a lot of very small requests in parallel instead. (At least task parallelization in .NET makes this simple...)
Thanks for being so understanding - closing now.

@giammin: Yes - each operation will now only create a single Write.

Was this page helpful?
0 / 5 - 0 ratings