I recently transitioned from Cassandra to DynamoDB, and found a difference between the two (pretty significant to me at least). The terms are a bit different, so for simplicity I will just call them partition key
and clustering key
.
In Cassandra we have this concept called composite key
- the partition key can be a multi-column value, as well as the clustering key. However, it looks like there's no such concept in DynamoDB. The AWS document mentions composite
, but it just means a primary key can be formed by <partition_key, clustering_key>:
Partition key and sort key – Referred to as a composite primary key, this type of key is composed of two attributes. The first attribute is the partition key, and the second attribute is the sort key.
I used the multi-column value (which is composite
in Cassandra's sense) as keys a lot in the past so I was kind of shocked when I realized it's not supported in DynamoDB. I know it's always an option to do concatenation like this post. My questions are:
- Is having a multi-column value as the partition key an anti-pattern? Is this also true for clustering key?
- Would a multi-column key cause performance degradation?
- If there's no performance degradation, then what are other tradeoffs behind these two implementations?