Home / Companies / Couchbase / Blog / Post Details
Content Deep Dive

Indexes for N1QL: or how I got an order magnitude speed increase

Blog post from Couchbase

Post Details
Company
Date Published
Author
Martin Esmann, Developer Advocate, Couchbase
Word Count
2,343
Language
English
Hacker News Points
-
Summary

N1QL query language is introduced in Couchbase 4.0, bringing SQL-like queries to JSON documents. The performance of N1QL queries heavily depends on the shape of the data and the system used. Creating indexes can significantly improve performance. A test bench was created to measure the execution time of N1QL queries with and without indexes. The results showed that using secondary indexes can greatly improve query performance, with a factor of 100 to 1000 improvement in some cases. However, creating too many indexes can impact the cluster's CPU usage. Creating indexes is essential for optimal performance, and the code provided allows users to easily create indexes with a single line of code.