简体   繁体   中英

Is there a way to retrieve all items without an attribute in DynamoDB?

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?

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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