简体   繁体   English

有没有办法在 DynamoDB 中检索没有属性的所有项目?

[英]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).因此,我最近向我的 DynamoDB 表(8.5 亿条记录)添加了一个生存时间属性。 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.我想在没有设置 Time To Live 属性的情况下检索此表中的所有项目,因此我可以使用 UpdateItem 用 Time To Live 回填这些项目。

Is there a way to do this in DynamoDB?有没有办法在 DynamoDB 中执行此操作?

If your database is small, a simple scan will work:如果你的数据库很小,一个简单的scan就可以了:

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.如果您的数据库很大,您可能需要考虑AWS 概述的更周到的方法,其中包括使用 AWS EMR 回填 DynamoDB 中的数据。 Bonus, the linked article discusses backfilling time to live attributes in DynamoDB!奖励,链接的文章讨论了 DynamoDB 中活动属性的回填时间!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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