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
asked 2 years ago7831 views
1 Answer
1
Accepted Answer

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
EXPERT
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions