2개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
1
The data in DynamoDB will be sorted order by the sort key you have defined. Sorting is only applicable to items which share the same partition key. Lets take an example of a table where we sort data by time, time being the sort key (SK)
PK | SK |
---|---|
sens-101 | 2022-10-26T17:30:00.000-04:00 |
sens-101 | 2022-10-27T17:30:00.000-04:00 |
sens-101 | 2022-10-28T17:30:00.000-04:00 |
sens-101 | 2022-11-21T17:30:00.000-04:00 |
sens-101 | 2022-11-22T17:30:00.000-04:00 |
sens-101 | 2022-12-01T17:30:00.000-04:00 |
sens-107 | 2022-10-26T17:30:00.000-04:00 |
sens-107 | 2022-10-27T17:30:00.000-04:00 |
sens-107 | 2022-10-28T17:30:00.000-04:00 |
sens-107 | 2022-11-21T17:30:00.000-04:00 |
sens-107 | 2022-11-22T17:30:00.000-04:00 |
sens-107 | 2022-12-01T17:30:00.000-04:00 |
sens-103 | 2022-10-26T17:30:00.000-04:00 |
sens-103 | 2022-10-27T17:30:00.000-04:00 |
sens-103 | 2022-10-28T17:30:00.000-04:00 |
sens-103 | 2022-11-21T17:30:00.000-04:00 |
sens-103 | 2022-11-22T17:30:00.000-04:00 |
sens-103 | 2022-12-01T17:30:00.000-04:00 |
Now you can see that each sensor data is sorted by the order of the sort key, but sorting is not across all sensors in the table.
관련 콘텐츠
- AWS 공식업데이트됨 일 년 전
Hi,
Thanks for your prompt response. I understood that we can sort data if we keep PK constant using sort key. As i said earlier, I have multiple devices which sends timeseries data to dynamodb. As a PK, I am using Device ID. As a sort key i am using a positive going number as it will sort out other attributes of data. I am not using time stamp as SK since in a single timestamp, multiple data is transmitted. due so, data get unordered.
Lets say If we want history of data @ some perticular time, then what to do? How do we fetch historical data from dynamodb?
Kindly note that data should be in order as they come from iot core.
Also what if PK and SK are constant & data attributes are changing?