且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

DynamoDB 中超过 2 列的复合键?

更新时间:2022-12-23 15:12:46

为此,DynamoDB 允许对基本上无限量的数据进行一致的低延迟查询.您建议的连接值的模型似乎是一个好方法.

DynamoDB allows consistent low-latency queries on essentially infinite amount of data for this. The model you suggested with concatenating the values seems to be a good approach.

需要注意的一点是,哈希键属性值限制为 2048 字节.如果您要连接的值不是可预测的长度(您不能很好地填充它们)或超过此限制,那么对项目的值进行散列并根据项目的散列进行搜索可能是一种更好的方法.以下是有关限制的相关文档:https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html.DynamoDB 项目的总数据也限制为 400KB.

One thing to note is that hash key attribute values are limited to 2048 bytes. If the values you are concatenating are not predictable lengths (you can't pad them nicely) or exceed this limit, it may be a better approach to hash the value of the item and search based on the hash of the item. Here is the relevant documentation on limits: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html. DynamoDB items are also limited to 400KB total data.

为了正确起见,我还将为范围键使用一些唯一标识符,这将允许哈希值发生冲突(即使它很少见),并且架构是可扩展的,因为每个哈希键值有少量项目.

For correctness, I would also use some unique identifier for a range key, this will allow collisions for hash values (even if it's rare) and the schema is scalable because there are a small number of items per hash key value.