【问题标题】:Is there a size limit on partition part of a composite primary key in AWS DynamoDB?AWS DynamoDB 中复合主键的分区部分是否有大小限制?
【发布时间】:2016-07-24 22:38:05
【问题描述】:

来自AWS DynamoDB documentation

如果将主键属性定义为字符串类型属性,则 以下附加限制适用:

  • 对于简单的主键,第一个属性值(分区键)的最大长度为 2048 字节。
  • 对于复合主键,第二个属性值(排序键)的最大长度为 1024 字节。

是不是说在复合主键的情况下,分区键的最大长度没有限制?

(通常每个项目的大小限制为 400 KB,但问题不在于那个)

【问题讨论】:

    标签: amazon-web-services amazon-dynamodb


    【解决方案1】:

    我很确定这只是说 2048 字节是所有分区键的限制,如果您碰巧有一个排序键,那么该排序键的限制为 1024 字节。这似乎也是他们在this page 上说的更清楚的内容。

    【讨论】:

      【解决方案2】:

      马克是对的。分区键限制为 2048 字节,与主键类型(单属性或复合)无关。我刚刚从命令行对其进行了测试。以下是我使用的命令。如果您在第二个命令中将 2048 更改为 2049,DynamoDB 将无法添加项目并出现 ValidationException 错误。

      # Create test table
      aws dynamodb create-table --table-name testdb5 --attribute-definitions '[{"AttributeName": "Id", "AttributeType": "S"}, {"AttributeName": "LastName", "AttributeType": "S"}]' --key-schema '[{"AttributeName": "Id", "KeyType": "HASH"}, {"AttributeName": "LastName", "KeyType": "RANGE"}]' --provisioned-throughput '{"ReadCapacityUnits": 5, "WriteCapacityUnits": 5}' 
      
      # Add an item
      aws dynamodb put-item --table-name testdb5 --item '{ "Id": {"S": '$(python -c "print '\"' + 'A'*2048 + '\"'")'}, "LastName": {"S": '$(python -c "print '\"' + 'B'*1024 + '\"'")'}}'
      
      # Delete an item
      aws dynamodb delete-item --table-name testdb5 --key '{ "Id": {"S": '$(python -c "print '\"' + 'A'*2048 + '\"'")'}, "LastName": {"S": '$(python -c "print '\"' + 'B'*1024 + '\"'")'}}'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-12-16
        • 2021-05-07
        • 2019-06-02
        • 1970-01-01
        • 2021-12-10
        相关资源
        最近更新 更多