TTL Value FAQs
How are TTLs used in databases?
In databases, TTLs are used to expire database records or data elements automatically. Functioning like an expiration date, TTL is the length of time data may remain in the database. Data can no longer be retrieved after it reaches its expiration timeout value, and it no longer appears in database statistics.
Documents stored in a database remain active by default unless a removal operation explicitly deletes them. For most scenarios, this is the desired behavior. However, for some use cases, it is more desirable to automatically dispose of older records or data elements and retain only the most recent data.
[Learn about database TTL in this free training course]
What databases support TTL?
Many databases support TTLs, including NoSQL databases such as ScyllaDB, Cassandra, and DynamoDB, or SQL RDBMS such as MySQL, Oracle, PostgreSQL, and SQL Server. TTLs are also frequently deployed in cache and storage systems such as RocksDB, Redis, and MyRocks.
Does ScyllaDB offer options for setting TTL value?
TTL values are features of both ScyllaDB and Apache Cassandra, but implementation varies across both of these databases.
In ScyllaDB, TTL for its Cassandra Query Language (CQL) interface can be set based on a number of seconds. It can be set for an entire row — deleting it entirely — or for a specific value per column for a non-primary key column.
The default TTL value is null, so the data will not expire — just define the TTL value when creating the table using the default_time_to_live feature. This behavior is similar to Apache Cassandra’s use of TTLs.
In addition, TTL can be set in ScyllaDB for data stored in Change Data Capture (CDC) log tables by using the cdc$ttl setting. This prevents the CDC tables from filling up your storage. Apache Cassandra manages CDC very differently and lacks this TTL feature for its CDC implementation.
Aside from this, the DynamoDB-compatible interface for ScyllaDB, known as Alternator, uses a different form of TTL. These TTLs are set at the attribute name level. Expirations in Alternator also have a deletion delay of up to 48 hours; by default, it is set to 24 hours. Since the Alternator interface is unique to ScyllaDB, Apache Cassandra has no comparable setting.
Learn more about how TTL value works in the ScyllaDB documentation and the ScyllaDB University lesson on expiring data with TTL.