Reputation: 325
So I recently added a Time To Live attribute to my DynamoDB table (850 million records). I'm trying to write a script to backfill the Time To Live attribute in my table.
I'm want to retrieve all the items in this the table without the Time To Live attribute set, so I can backfill these items with the Time To Live using UpdateItem.
Is there a way to do this in DynamoDB?
Upvotes: 0
Views: 1306
Reputation: 5747
If your database is small, a simple scan
will work:
var params = {
TableName: "<YOUR TABLE NAME>",
FilterExpression: "attribute_not_exists(time_to_live)"
};
var results = dynamodb.scan(params);
// update records here
If your DB is large, you may want to consider the more thoughtful approach outlined by AWS, which includes using AWS EMR to backfill data in DynamoDB. Bonus, the linked article discusses backfilling time to live attributes in DynamoDB!
Upvotes: 1