What is the recommended way to delete a large number of items from DynamoDB?

前端 未结 7 2100
情歌与酒
情歌与酒 2020-11-29 21:51

I\'m writing a simple logging service in DynamoDB.

I have a logs table that is keyed by a user_id hash and a timestamp (Unix epoch int) range.

When a user of

相关标签:
7条回答
  • 2020-11-29 22:40

    According to the DynamoDB documentation you could just delete the full table.

    See below:

    "Deleting an entire table is significantly more efficient than removing items one-by-one, which essentially doubles the write throughput as you do as many delete operations as put operations"

    If you wish to delete only a subset of your data, then you could make separate tables for each month, year or similar. This way you could remove "last month" and keep the rest of your data intact.

    This is how you delete a table in Java using the AWS SDK:

    DeleteTableRequest deleteTableRequest = new DeleteTableRequest()
      .withTableName(tableName);
    DeleteTableResult result = client.deleteTable(deleteTableRequest);
    
    0 讨论(0)
提交回复
热议问题