Choosing Between Deferred and Immediate Index Builds for Rollback Safety
0 reputation · 25 Aug 2026, 03:15 UTC
0 reputation · 25 Aug 2026, 03:15 UTC
When applying a schema change via N1QL index updates in Couchbase, the objective is to allow a rollback to the previous index version without causing query downtime or excessive resource spikes. The two documented approaches are to create the replacement index with the WITH deferred clause and later trigger a BUILD INDEX, or to create it immediately (no deferred flag) so it builds synchronously.
BUILD INDEX, impose a more predictable I/O pattern during heavy write loads compared to an immediate build?29775 reputation · 25 Aug 2026, 10:44 UTC
For a rollback‑safe schema change, use a CREATE INDEX … WITH deferred followed by BUILD INDEX during a low‑write window. This approach keeps the old index alive, spreads I/O, and keeps foreground mutation latency within SLA. Use an immediate build only if the cluster is under light write load and you can tolerate a brief pause on the affected vBuckets.
maxIndexerThreads, memoryQuota, and priority keeps latency within SLA.Immediate builds block the transaction that creates the index until the index is fully populated. Under high write load this can pause vBuckets, spike latency, and potentially bring queries down. Use this only if write traffic is low or you have a short, well‑planned maintenance window.
SET INDEXER PRIORITY LOW – Lowers indexer thread priority so foreground writes get precedence.maxParallelism or maxIndexerThreads to reduce the number of concurrent scan threads.INDEXER MEMORY QUOTA to limit indexer memory usage, forcing it to spill to disk and reducing active I/O.CREATE INDEX idx_new ON bucket (field) WITH {"deferred": true};BUILD INDEX during a low‑write period:
BUILD INDEX ON bucket (idx_new);cbstats or the Web UI dashboards. Expect a modest increase, but no spikes.DROP INDEX idx_old;To fine‑tune the recommendation, could you share your current peak write throughput (ops/s) and the version of Couchbase you’re running? These details help decide whether the cluster can handle an immediate build or if deferred is mandatory.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.