A newer version of this documentation is available.

View Latest

Indexes

      +

      This guide explains how to create and use primary and secondary indexes for N1QL queries.

      Creating Indexes

      You must create an index on a keyspace to be able to query that keyspace. The Index service enables you to create two types of index: primary indexes and secondary indexes.

      Index Placement

      To improve query responsiveness, you can choose where to save primary and secondary indexes. You can also partition a large secondary index across multiple nodes. In Couchbase Server Enterprise Edition, you can create replicas of primary indexes, secondary indexes, and secondary index partitions, to enhance index availability.

      Deferring Indexes

      When you create a primary or secondary index, you can mark it as deferred. This means the index is not built at once; you can build the deferred index later. This enables you to build multiple indexes more efficiently.

      Selecting Indexes

      Couchbase Server attempts to select an appropriate secondary index for a query, based on the filters in the WHERE clause. You can use an index hint to specify that a query should use a particular index.

      Dropping Indexes

      You can drop primary and secondary indexes when you do not need them any more.

      Related Links

      Refer to the following guide for information on the Index Advisor, and other optimization features.