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

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ