Coucbase partition key vs Primary key

Hi All,
In couchbase always primary key is the partition key?Do users have the freedom to pick partition key and primary key separately like in cassandra?

Lets say primary key in couchbase is ( A ,B,C)
Can we have partition key as (A,B) in couchbase?

Or is it always primary key is fixed as partition key in couchbase to distribute data across dataservice bucket nodes?
Also does couchbase support clustered columns to sort data within a data service bucket node?

Thanks,
Isuru

If you are looking this global secondary index prespective.

As long as A,B immutable you can create secondary GSI index PARTITION BY HASH (A,B).

Thanks vsr1.
It is clear that couchbase allow only indexes to be partitioned by hash where as in cassandra data itself can be partitioned by hash key.

Does couchbase support composite hash so that you can partition the index where hash key is composite(A,B) type? i.e PARTITION BY HASH(A,B,etc)?

Please clarify

Thanks
Isuru

Speaking for the primary data service, and the analytics service may have some other options… In the early days of Couchbase we discussed whether or not we should allow applications to define a hash key in addition to the key. We decided to keep it simple and while we left some room for doing that architecturally, the only implementation we have at the moment is hashing by the full key.

Technically what we do is hash to a logical partition where we have a large number of logical partitions, then we map those logical partitions to the nodes in the cluster. By doing this, we can redistribute data as needed without needing to visit all data on a given node. We also take advantage of this hashing all the way down to the client library, so when your app needs to retrieve a piece of data through the KV interface, it knows exactly which node to go to which lets us keep memcached like latencies/throughputs.

Hopefully that helps a bit.

Based on where your description of use case is going, it sounds a bit more analytical rather than operational? Maybe you can describe your data access goals a bit and we can help you with how best to structure that between data/analytics to meet your goals.

HI ingenthr,
My question is on indexes of couchbase.
Does couchbase support composite hash so that you can partition the index where hash key is composite(A,B) type? i.e PARTITION BY HASH(A,B,etc)?

Please clarify.

THanks

My apologies, I thought you were asking about primary key specifically, not separately defined indexes. I’ve pinged a couple of other people who may be able to help in the thread.

Yes. Secondary Partition index supports composite PARTITION BY HASH(A,B,etc)? Only requirement is it is immutable.

Check example at the end of Queriability section of Example Couchbase GSI Index partitioning | The Couchbase Blog

Thanks @vsr1 for the clarifications.