Company
Date Published
Author
Binh Le
Word count
1362
Language
English
Hacker News points
None

Summary

Couchbase 7.0 introduces cost-based optimization (CBO) for NoSQL document databases, a significant advancement from the previous rule-based optimization (RBO) approach. Unlike RBO, which might use all possible indexes for query execution, CBO computes the cost of each potential execution path using pre-computed statistics to determine the most efficient plan, particularly when multiple indexes are available. This optimization requires both enabling the CBO feature and collecting relevant statistics on index fields to function effectively. Examples with the Couchbase travel-sample dataset illustrate how CBO can optimize queries by selecting the most cost-effective index for operations like index selection and JOINs. Although CBO is enabled by default, it necessitates regular updates to statistics to maintain efficiency, and it can be disabled if needed through specific settings.