In the previous post, we saw the benefits of using index replicas over equivalent indexes.  Let’s say you are on Couchbase Server 4.x and have the following 3 equivalent indexes spread across 3 nodes; and with Couchbase 5.0 Beta available, you want to migrate these equivalent indexes to Index Replicas.

Note: If you want to use the same nodes to create the replicas, do make sure that they have the required memory and compute resources for the both the index replicas and equivalent indexes to coexist.

Step 1: Fire the following query with the num_replica parameter being 2, as we earlier had 3 copies of the index and want to maintain the same topology of indexes.

If you are bringing in a new set of 3 index nodes, then you might as well specify the ‘create index’ statement with the ‘nodes’ parameter set; for example:

Step 2: Once Step1 completes and all the index replicas are created and online(i.e, index build completed), drop the old 4.x equivalent indexes present.

Voila!! Your N1QL queries are all set to use the index replicas, and there was no application downtime during the process as well. If you had used ‘USE INDEX’ directive in your N1QL query, then the same needs to be updated with the new index name.

Equivalent indexes are still supported in Couchbase Server 5.0 and a mix of equivalent and replica indexes also works, i.e.,  N1QL queries would load balance between equivalent and replica indexes; but for efficient manageability, index replicas are recommended over equivalent indexes.

If you haven’t already, click here to download Couchbase Server 5.0 and play around with Index Replicas. 

Posted by Venkat Subramanian, Product Manager

Venkat is a Product Manager at Couchbase and is responsible for many facets of the Couchbase Server. He has over a decade of experience in product development and management and has been developing data/analytics platforms & products. Significant chunk of his experience has been with Oracle, where he transitioned from being an Engineer in Oracle’s Enterprise Manager team to Product Manager for Oracle's BI/Analytics suite of products. He has worked in startups in the past helping develop NLP products and distributed decisioning systems. He has done Bachelors in Computer Science from University of Madras (India) and has done Executive General Management from Indian Institute of Management(I.I.M), Bangalore (India); and lurks around at @venkasub.

Leave a reply