Bulk documents update using N1QL update


I tried updating bulk documents using the n1ql update query. The issue I have faced was that only a subset of documents was getting updated in the first try, a little more in the second try and so on without change the condition in WHERE part. Is this a bug in couchbase server or a limit on the number of documents getting updated in one single query. I am using couchbase version
Enterprise Edition 5.1.0 build 5552.

Shubham Goel

1 Like

You need to be more specific. Did you got error. what is error. Post actual update with explain and index definition.

I did not get any error, I got usual response i.e. empty array after executing the update query.

QUERY: Update bucket_name SET channel=[‘value’]
where companyId = ‘value2’
AND locationId = ‘value3’" AND Meta(bucket_name).id NOT LIKE “%_sync%”

Index Definition: I did not specifically had an index for this query, because I was not concerned with latency, I wanted to execute a backward migration script in background.

CREATE INDEX ix1 ON  bucket_name(companyId, locationId) 
WHERE META().id NOT LIKE "%_sync%";

Also check Status of the update

Can you tell why partial mutations without creating index, from my understanding indexing is used to avoid latency? And one more thing I tried now without indexing on query workbench it worked fine, sometimes it causes partial mutations, and sometimes it works as excpected.

Without index it might use primary index. get all documents and apply filters and discard entries.
Lot of unnecessary work. Also check any timeout . Any index is eventual consistent if index is not up to date on mutations those might not updated.

  1. Got the primary index point.
  2. index is not up to date - how to ensure the index is up to date, do primary index not get update ?
  3. Also check any timeout - what is the problem in timeout, and I do have any timeout, you are basically referring timeout as “execute the query after fixed millisecond”?

Couchbase index are eventual consistence. If you want you use scan_consistency (check documentation).
While executing query user can set timeout. status of query gives if any tieout.

I think I will have to read the documentation as there is a gap in my knowledge, so then I should proceed further with the discussion, but I got an overview. Thanks for helping out.