When Does TTL in DynamoDB Actually Delete Records?
Asked by
680nm absorption
Hey everyone! I've set up a DynamoDB table and enabled Time to Live (TTL), added a field for expiration, and ran some simulations. According to that, two records are supposed to be deleted after 'X' amount of time. However, 'X' time has passed, and I still see those records. It's been less than an hour since I activated TTL. Can anyone tell me how long it actually takes for DynamoDB to delete records based on TTL?
Answers
Yeah, when they say 'within a few days', they mean it! It usually doesn't take that long, but don't expect immediate deletion right after the TTL hits. Just make sure to check if the item still exists based on the current time vs. the TTL timestamp for more accurate handling.
Reply to this answer
TTL management is done as a background process in DynamoDB. It might only get enforced when things like partition keys are restructured, which means thereโs no set timeframe for deletion. Always check your itemsโ TTL in your app as a fail-safe!
aqua aerobics: Good point! That's a smart approach to ensure youโre not relying solely on TTL for data validity.
Reply to this answer
To manage your records better, consider using a filter expression in your queries, so you only retrieve valid records and avoid confusion with the expired ones!
Reply to this answer
Items with expired TTL attributes can be deleted at any time, usually within a few days of their expiration. So donโt worry too much about it yet! Just keep an eye on it for a couple more days.
Reply to this answer
Add your answer
Answers are reviewed before publication.
AERIAL SURVEY: Definitely! It's safer to verify whether items have actually expired before assuming they've been deleted.