Introduction
Removing old data from dynamodb using a date attribute.
My use case: removing old data from dynamodb using a date attribute.
Important things to know:
- You can't query a table with using only range key attribute (date for example).
- You can only query a table using hash or hash+range key.
- You can't query a table using a hash key with '<' / '>' operations, only '='.
Possible Solutions:
- Scanning the whole table - this could be very costly
- My chosen solution - Defining an index with range key for the date and with a hash key that would be pretty decent such as the day of year.
Eventually batch delete the result set.
Notes:
Building the entity I was using the amazon dynamo annotations.
I was using DynamoDBQueryExpression to query, getting the result page with the defined Class object.