Preferred Option for Deletion of Old Items in DynamoDB Table

Delete Old Items in a DynamoDB Table

Prev Question Next Question

Question

An Amazon DynamoDB table is populated with a large amount of data from an application capturing client data from various servers across various regions.

Which of the following is a preferred option for deletion of old items in a DynamoDB table?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer - D.

Amazon DynamoDB TTL can delete items in a DynamoDB table based upon the TTL values you specify.

TTL is specified as a timestamp for items in a table.

This is an easier way of deleting old items & thus freeing up space & saving cost.

Option A is incorrect as although this will work.

But additional admin work will be required to create & run jobs.

Option B is incorrect as this will require additional manual jobs to run to delete old items.

Option C is incorrect.

This will require adding additional logic in an application to switch over to new tables after a specific time for which DynamoDB tables are pre-created.

For more information on TTL for DynamoDB, refer to the following URLs-

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/howitworks-ttl.html https://aws.amazon.com/blogs/database/automatically-archive-items-to-s3-using-dynamodb-time-to-live-with-aws-lambda-and-amazon-kinesis-firehose/

The preferred option for deletion of old items in a DynamoDB table is to enable TTL (Time to Live) on each item to automatically delete old items.

TTL is a feature in DynamoDB that automatically deletes items from a table after a specified amount of time has passed. This feature can be enabled on a per-item basis by adding a TTL attribute to the item. The value of this attribute is a timestamp that specifies when the item should be deleted.

Enabling TTL on each item has several benefits. Firstly, it eliminates the need for manual deletion of old items, which can be time-consuming and error-prone. Secondly, it ensures that old items are deleted in a timely manner, which helps keep the size of the DynamoDB table under control. Finally, it allows you to focus on more important tasks, such as analyzing the data that remains in the table.

In contrast, the other options are less desirable. Scheduling a cron job during off-peak hours to delete unwanted items requires manual intervention, which can be error-prone and time-consuming. Running periodic jobs to delete old items is also less desirable because it requires more overhead and can impact the performance of the DynamoDB table. Pre-creating a DynamoDB table with a specific time is not a viable solution because it is not dynamic enough to handle changing data over time.

In summary, enabling TTL on each item is the preferred option for deleting old items in a DynamoDB table because it is automatic, timely, and requires minimal overhead.