1

We have an old version of Order document in our couchbase(in millions) which we need to update with customer id from a Customer document. We came up with the following query to do so :

MERGE INTO `order_bck` orderdoc
USING (SELECT customer.customerInformation.uuid AS uid, customer.customerInformation.customerId as customerId
FROM `order_bck` AS custInfo WHERE META(custInfo).id LIKE ':custInfo:%') AS source
ON orderdoc.uid = source.uid
WHEN MATCHED THEN
UPDATE SET orderdoc.customerId = source.customerId WHERE META(orderdoc).id LIKE ':orderdoc:bck:%;

The Customer document and the Order doc have a matching UID. So the query basically updates the customer Id into the Order document which it gets from the customer document which has a matching UID with an Order document.

Couchbase version : 6.6.1

Problem: This query doesn't update all the Order documents consistently. Sometimes it does other times some random number of Order documents get updated. However, every time we get a success message in the response. We are updating using the cbq utility of Couchbase. I also set an infinite timeout i.e. 0 however observed the same behavior.

Questions:

  1. Is there a problem with the query? I don't think so as it does update all the required documents sometimes. Also its not a live system so the number of documents is static.
  2. Which Couchbase logs should I check to debug and figure out other kinds of issues like memory or network etc.or any other potential issue?
Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
humbleCoder
  • 667
  • 14
  • 27
  • If you are updating million use eventing https://docs.couchbase.com/server/current/eventing/eventing-examples.html – vsr Sep 07 '21 at 19:06
  • Our use case is a bit different. We need the customer Id in all documents before going live and not on some event. – humbleCoder Sep 08 '21 at 04:00
  • Please note, that Eventing can indeed do exactly what you need (I leave your N1QL issue for someone else). Eventing can process all documents with a feed boundary of "From now" or a feed boundary set to "Everything" that latter allows Eventing Function to act as a one off point tool to enrich your data. Deploy the Function, enrich all docs of interest, then undeploy the Function. Refer to both https://docs.couchbase.com/server/current/eventing/eventing-example-data-enrichment.html (case 2) and https://forums.couchbase.com/t/what-is-the-fastest-way-to-update-several-million-docs/29745/3 – Jon Strabala Sep 08 '21 at 19:16

0 Answers0