A newer version of this documentation is available.

View Latest

View indexes for N1QL

Definition

You can define a primary or secondary index using view indexes in N1QL using the CREATE INDEX statement. When using view indexes in N1QL, the index definition is fixed and cannot be changed through the Couchbase Web Console or the command line.

Distribution

Data nodes hash partition data so that data is uniformly distributed across the cluster. View indexes are co-located with the data and each view index contains only a subset of the data that is available on the node.

n1ql view indexes distribution
Figure 1. View distribution
Latency

View indexes have a higher latency compared to GSI indexes. View indexes are based on scatter-gather architecture where the server scatters the request to other data nodes where the partial view resides, and then gathers the data responses back. As the number of nodes grows, the latency also increases.

Scaling

View indexes are co-located with data and hence cannot be individually scaled.

Load-balancing

View indexes are based on the scatter-gather architecture which touches all the nodes in the cluster. Since all the nodes in the cluster are touched, there is no load-balancing.

Consistency

When using view indexes, the default consistency setting is update_after. When using view indexes in N1QL, the index definition is fixed and cannot be changed through the Couchbase Web Console or the command line.

Replication

View indexes are replicated and the replica index is co-located with the replica data. If the primary copy of the index is not available, the replica index is queried to retrieve data.