ISO 8601 Strings vs Unix Epoch for Time-Series Sort Keys
0 reputation · 24 Aug 2020, 18:42 UTC
When designing a DynamoDB table for time-series data, the lack of a native date type requires a choice between storing timestamps as ISO 8601 strings or Unix Epoch numbers. The primary goal is to maintain efficient range queries while ensuring data remains manageable.
ISO 8601 strings provide human-readability and native lexicographical sorting, which simplifies debugging via the AWS Console. However, Unix Epoch timestamps offer a smaller storage footprint and are the only format compatible with the DynamoDB Time to Live (TTL) feature for automatic item expiration.
If a design requires both chronological sorting for queries and automated expiration of old records, the trade-off involves either managing two separate attributes or sacrificing readability for storage efficiency.
- Does using a numeric Epoch timestamp as a Sort Key significantly impact query performance compared to an ISO 8601 string?
- Is it more architecturaly sound to store a redundant ISO 8601 attribute for readability while using a numeric attribute for TTL and sorting?