0
votes

I am new to Amazon DynamoDB. I was going through the documentation and here it clearly stats that ONE KEY CAN BELONG TO ONLY ONE PARTITION BUT ONE PARTITION CAN HAVE MULTIPLE KEYS. My Question here is:

Lets say my partition1 has two keys S1 and S2. On reaching the threshold like 10GB of size or 3000 RCU or 1000 WCU DynamoDB will create new partition and move S2 key in new partition i.e. partition1_0.

But how the key sharding will happen now since both partition has single key i.e partition1 has S1 and partition1_0 has S2 and if partition1 is again breaching the threshold and new partition is created can we expect key S1 in two partition.

Let me know if my question is not clear.

1

1 Answers

2
votes

The answer is actually in the documentation, you will get an error from DynamoDB. Although I believe the 10gb limit is only a problem when you have a Local Secondary Index, otherwise there is no practical limit to the amount of data:

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LSI.html#LSI.ItemCollections.SizeLimit

If an item collection exceeds the 10 GB limit, DynamoDB will return an ItemCollectionSizeLimitExceededException and you won't be able to add more items to the item collection or increase the sizes of items that are in the item collection. (Read and write operations that shrink the size of the item collection are still allowed.) You will still be able to add items to other item collections.

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html#limits-partition-sort-keys

Sort Key Values

In general, there is no practical limit on the number of distinct sort key values per partition key value.

The exception is for tables with local secondary indexes. With a local secondary index, there is a limit on item collection sizes: For every distinct partition key value, the total sizes of all table and index items cannot exceed 10 GB. This might constrain the number of sort keys per partition key value. For more information, see Item Collection Size Limit.