All Products
Search
Document Center

PolarDB:Overview

Last Updated:Mar 28, 2026

TTL (time to live) is a native lifecycle management feature in PolarDB for MySQL that automatically deletes expired rows without requiring application-side scheduled jobs.

Use cases

  • Session and token cleanup: Automatically expire authentication tokens, verification codes, and short-lived session records.

  • Message and event retention: Delete chat messages, notifications, or event logs after a defined retention period.

  • Order and transaction history: Remove historical order records that are no longer needed for business operations.

  • Compliance-driven data deletion: Enforce data retention policies by automatically purging records after the required retention period ends.

  • Intermediate computation results: Clean up temporary rows written during batch processing or workflow execution.

How it works

PolarDB for MySQL implements TTL at the storage engine level:

  • Each table with TTL enabled has a designated timestamp column that determines when a row expires.

  • A background job periodically scans for rows whose timestamp column value falls before the expiration threshold.

  • Expired rows are deleted, keeping the impact on foreground query performance low.

  • Because deletion is asynchronous, there is a window between a row's expiration time and its actual removal.

This approach is more reliable than using the MySQL event scheduler or application-layer scheduled jobs, which require careful tuning to balance deletion timeliness against performance impact.

Supported versions

TTL is available in clusters running the following engine versions:

  • PolarDB for MySQL 8.0.1, revision version 8.0.1.1.49 or later

  • PolarDB for MySQL 8.0.2, revision version 8.0.2.2.27 or later

To check the engine version of your cluster, see Query the engine version.