简体   繁体   English

在DynamoDB中存储时间序列数据

[英]Storing timeseries data in DynamoDB

I am trying to store a bunch of network measurements in DynamoDB and I am not sure of the correct partition key and range key. 我正在尝试在DynamoDB中存储一堆网络测量结果,但是我不确定正确的分区键和范围键。 My data will look like this: 我的数据将如下所示:

{
count: 33,
total: 45,
timestamp: 21231133,
data: {
    key1: value1,
    key2: value2,
    key3: value3,
    key4: value4,
    key5: value5}
}

I need to be able to retrieve data that has a timestamp between timestamp1 and timestamp2. 我需要能够检索时间戳介于timestamp1和timestamp2之间的数据。 I will be storing the data every second, and retrieving at a slower interval (maybe every 30 seconds). 我将每秒存储一次数据,并以较慢的时间间隔(也许每30秒)进行检索。

I need to avoid hot-partitions and still be able to quickly query the data. 我需要避免热分区,并且仍然能够快速查询数据。 I would not want to do a table scan. 我不想做表扫描。

Thanks, 谢谢,

Based on the query pattern mentioned in the question, I think "timestamp" attribute should be a PARTITION key. 基于问题中提到的查询模式,我认为“ timestamp”属性应该是PARTITION键。 You can use BETWEEN operator when you define the attribute as String , Number or Binary. 将属性定义为String,Number或Binary时,可以使用BETWEEN运算符。

On this table data, I don't see any attribute that can be used as RANGE key unless you have any other query pattern or use case. 在此表数据上,除非您有任何其他查询模式或用例,否则我看不到任何可用作RANGE键的属性。

BETWEEN : Greater than or equal to the first value, and less than or equal to the second value. BETWEEN:大于或等于第一个值,并且小于或等于第二个值。 AttributeValueList must contain two AttributeValue elements of the same type, either String, Number, or Binary (not a set type). AttributeValueList必须包含两个相同类型的AttributeValue元素,即String,Number或Binary(不是集合类型)。 A target attribute matches if the target value is greater than, or equal to, the first element and less than, or equal to, the second element. 如果目标值大于或等于第一个元素且小于或等于第二个元素,则目标属性匹配。 If an item contains an AttributeValue element of a different type than the one provided in the request, the value does not match. 如果一项包含的AttributeValue元素类型与请求中提供的类型不同,则该值不匹配。 For example, {"S":"6"} does not compare to {"N":"6"}. 例如,{“ S”:“ 6”}与{“ N”:“ 6”}不进行比较。 Also, {"N":"6"} does not compare to {"NS":["6", "2", "1"]} 此外,{“ N”:“ 6”}与{“ NS”:[“ 6”,“ 2”,“ 1”]}的比较

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

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