简体   繁体   English

AWS DynamoDB-分区密钥和密钥分片

[英]AWS DynamoDB - Partition key and Key Sharding

I am new to Amazon DynamoDB. 我是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. 可以说我的partition1有两个键S1和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 ie partition1_0. 达到阈值(如10GB大小或3000 RCU或1000 WCU)时,DynamoDB将创建新分区并将S2密钥移到新分区(即partition1_0)中。

But how the key sharding will happen now since both partition has single key ie 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. 但是,由于两个分区都具有单个密钥,即分区1具有S1,分区1_0具有S2,并且现在如果分区1再次超出阈值并创建新的分区,密钥拆分现在将如何发生,我们可以期望两个分区中的密钥S1。

Let me know if my question is not clear. 如果我的问题不清楚,请告诉我。

The answer is actually in the documentation, you will get an error from DynamoDB. 答案实际上在文档中,您将从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: 尽管我相信10gb的限制仅在您具有本地二级索引时才是问题,但否则对数据量没有实际的限制:

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LSI.html#LSI.ItemCollections.SizeLimit 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. 如果项目集合超出10 GB的限制,DynamoDB将返回ItemCollectionSizeLimitExceededException,并且您将无法向该项目集合添加更多项目或增加该项目集合中项目的大小。 (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 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. 对于本地二级索引,项目集合的大小受到限制:对于每个不同的分区键值,所有表和索引项目的总大小不能超过10 GB。 This might constrain the number of sort keys per partition key value. 这可能会限制每个分区键值的排序键数。 For more information, see Item Collection Size Limit. 有关更多信息,请参见项目集合大小限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM