FROM ORDERS o INNER JOIN CUSTOMER c ON KEYS o.cid
WHERE o.zip = 58238;
In couchbase JOINS, we use indexes on the leading bucket (keyspace).
In this case, the index will be used on ORDERS for the predicate (o.zip = 58238).
As the index streams the qualified document IDs, N1QL engines does a KV GET on the CUSTOMER – no further index required.
Yes. You can do the query with predicates on both (or any number of keyspaces or predicates). We’ll use the index for the first scan and do the filtering on other key spaces after the get and join operation.