TRUNCATE DynamoDB table

0

Hi there,

I have a DynamoDB configured with GSI. And there is my table info.

Item countTable sizeAverage item size
11,02344.4 megabytes4,028.76 bytes

I want to truncate the table and is looking for the simplest and minimal impact way. Here are my research so far, but some articles do mention "truncate" operation on UI to be able to empty the data of a table, but I cannot find it myself in the AWS console UI.

  • solution 1. delete + re-create table will do the work,
  • solution 2. would be batch scan and delete using bash + CLI

Thanks for your time! Leo

Leo
已提问 2 年前8352 查看次数
1 回答
1
已接受的回答

Hi Leo,

Let me give you an overview of the options you've mentioned:

Delete and Re-Create Table: This option is cheapest, and possibly the easiest approach. There is no cost involved when dropping a table, likewise for creating one. However, keep in mind that this option could provide additional work in the case you use Infra as Code such as CFN or CDK. Also, you would have to recreate all of your additional settings such as Streams, AutoScaling, IAM Roles etc....

  • Fast
  • Cheap
  • May add additional operational overhead

Scan and Delete: For 11k items this will be relatively fast and easy to do, but there is a cost associated with it. You must pay for the capacity used from both the Scan and the BatchWrite Deletes. With AVG item size being just over 4kb, you will be charged 5WCU per item. However, for a one off that may be minimal: $1.25 per million write request units.

  • Relatively fast but not scalable
  • Can cost at scale
  • Requires you to write the code logic and provision compute to execute

Truncate via the console is possible, however, it will only do up to a maximum of 300 items per go which can be time consuming. You would also be paying for the Scan operations and the DeleteItem operations being carried out on your behalf.

profile pictureAWS
专家
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则