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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南