카우치베이스 서버

How to transition from Equivalent Indexes to Index Replicas?

2 분 읽기

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.

//old 4.x equivalent indexes
create index eq_index1 on bucket(field1); 

create index eq_index2 on bucket(field1); 

create index eq_index3 on bucket(field1);

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.

create index eq_index on bucket(field1) with {“num_replica”:2}

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:

create index eq_index on bucket(field1) with {“nodes” [“10.10.10.1:9001", "10.10.10.2:9002", "10.10.10.3:9003”]}

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.

drop index eq_index1; 
drop index eq_index2; 
drop index eq_index3;

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. 

이 기사 공유하기

작가

Venkat dabbles in product development and product 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 machine-learning/NLP products and distributed decisioning systems. He lurks around at @venkasub.

2개의 응답

  1. Hemant Masta 아바타
    Hemant Masta

    Nice blog Venkat. Can I increase the num_replica in 5.1 without recreating index ?

    1. Venkat Subramanian, Product Manager 아바타
      Venkat Subramanian, Product Manager

      Thanks Hemant. As of now, it is not possible. ALTER INDEX(introduced in 5.5) allows you to change index placements.

댓글 남기기

카우치베이스 카펠라를 시작할 준비가 되셨나요?

개발 시작하기

NoSQL을 탐색하고, 리소스를 찾아보고, 튜토리얼을 시작하려면 개발자 포털을 확인하세요.

카펠라 프리 사용하기

단 몇 번의 클릭으로 카우치베이스(Couchbase)를 직접 체험해 보세요. Capella DBaaS는 시작하기 가장 쉽고 빠른 방법입니다.

연락해

Couchbase 제품군에 대해 더 알고 싶으신가요? 저희가 도와드리겠습니다.