DELETE query performance

I have the following query

DELETE FROM my-db where shopInfo.shopId in [ “uuidxx123” ]

that uses the index

Index Currently Used
CREATE INDEX adv_shopInfo_shopId ON my-db((shopInfo.shopId))

Existing indexes are sufficient.

This query took 9 mins to complete for a total mutation of around 150k records.

Why does this query perform so poorly in spite of having an index and no other suggested indexes?

I believe the index should be on the individual shopids, not on the whole array. See Example 1 in Array Indexing | Couchbase Docs. Note that the predicate must match the index definition. If you write your query like this, Index Advisor will show you the index to create

DELETE FROM my-db WHERE ANY sid IN shopInfo.shopId SATISFIES sid IN [“uuidxx123”] END;

1 Like


You might want to review the following post showing how Eventing can be used as a one-off tool to quickly select and remove documents:


Jon Strabala
Principal Product Manager - Server‌

1 Like

The query system is designed for interactive applications to allow lots of concurrent queries and transactions. So, the resource and other defaults are designed for much smaller number of documents for each query. You’ll need to configure pipelinecap/scancap to improve the perf when handling large number of docs in a single query. See: Settings and Parameters | Couchbase Docs

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.