Abstract Couchbase is a distributed JSON database. It provides distributed data processing, high-performance indexing, and declarative query language N1QL along with search index, eventing, and analytics. N1QL (Non First Normal Query Language) is SQL for JSON. N1QL is to JSON what SQL is to relations. Developers say what needs to be done and the N1QL engine will figure out the "how." Current N1QL optimizer is a rule-based optimizer . Cost-Based Optimizer (CBO) for SQL was invented at IBM some 40 years ago and has been critical to the success of RDBMS and the developer/DBA productivity. NoSQL databases were invented some 10 years ago. Shortly after their invention, NoSQL databases started adding SQL-like query language with limited access paths and optimizer capabilities. Most use a rule-based optimizer or simply support cost-based optimization on simple scalar values (strings, numbers, boolean, etc.) only. To create a CBO on a JSON model, you first need to colle...