Skip to main content

Posts

Showing posts from July, 2016

Join faster with Couchbase Index Joins

[This article is reposted from my DZone article: https://dzone.com/articles/join-faster-with-couchbase-index-joins] Good features in query language help you to optimize the data model, save space, and increase performance. Normally, you’d have child table pointing to parent. For example, orders have the document key of the customer. So, starting with orders, you join customers to have the fully joined document which can be processed further.   To get the list of orders by zipcode, you write the following query. SELECT c .C_ZIP , COUNT (o .O_ID ) FROM ORDERS AS o LEFT OUTER JOIN CUSTOMER AS c ON KEYS o .O_CUSTOMER_KEY GROUP BY c .C_ZIP ORDER BY COUNT ( 1 ) desc ; This works like a charm. Let's look at the query plan. We use the primary index on ORDERS to do the full scan.   For each document there, try to find the matching CUSTOMER document by using the ORDERS.O_CUSTOMER_KEY as the docum...