Database / ScyllaDB Interview questions
How do you apply TTL to data in ScyllaDB?
Time-to-live (TTL) can be set per-write in seconds, either on an individual INSERT/UPDATE statement or as a table-wide default, after which the data is automatically marked for deletion.
INSERT INTO sessions (session_id, user_id, data) VALUES (uuid(), 'user123', 'payload') USING TTL 3600; -- expires in 1 hour CREATE TABLE cache (k text PRIMARY KEY, v text) WITH default_time_to_live = 86400;
Once a row or column's TTL elapses, it isn't deleted immediately; ScyllaDB writes a tombstone that marks it as expired, and the underlying data is physically removed later during compaction. TTL is a common building block for session data, caches, and rate-limiting counters, but heavy TTL usage benefits from the Time-Window Compaction Strategy, since TWCS is specifically designed to purge fully-expired SSTables efficiently.
More Related questions...