Bulk subdocument Update API


We have to update one field in large of documents and calling mutate in multiple time is take more time.

Can we do this in bulk like how we did upset?


Hey Akhil,

If you’re updating many fields in a single document, a replace() operation is probably most appropriate. Unless these documents are very, very large and you don’t mind the CPU time on the cluster side, it’d be no different to fetch, modify, and replace.

The amount of work is the same in both cases. We kept the Sub-Document API small since in most cases, you don’t want to be doing large document mutations at the KV service itself.

In general, to use more CPU time on the app side (at the cost of network transfer), work with the full document. To use more CPU time on the KV Service side (with minimal network transfer), use Sub-Document operations.

Network transfer is usually pretty cheap these days for most documents.

Hope that helps,


Also you might consider the Eventing Service it can be very performant to do bulk transformations. For example: N1QL CBQ Update million records is not working - #5 by jon.strabala

Note although Eventing does not use a sub-document API it still might be the right solution.

Essentially get a copy of the entire document super fast via DCP and are free to use JavaScript to manipulate it as much as you want in a fast v8 lambda and then you write the entire document back when done.


Jon Strabala
Principal Product Manager - Server‌