ql icon indicating copy to clipboard operation
ql copied to clipboard

Do you have plans to support expirable rows (rows with TTL)?

Open didip opened this issue 7 years ago • 4 comments

I couldn't find such info in your godoc.

Some data are transient by nature, it would be nice for ql to support rows with TTL.

didip avatar May 17 '18 16:05 didip

Is there an example of some other SQL supporting this?

Anyway, purging "dead" records from a table should be a simple DELETE ... WHERE ... statement, IIUC.

cznic avatar May 18 '18 08:05 cznic

The most popular use-case is Cassandra's USING TTL example: https://docs.datastax.com/en/cql/3.3/cql/cql_using/useExpireExample.html

INSERT INTO cycling.calendar (race_id, race_name, race_start_date, race_end_date) VALUES (200, 'placeholder', '2015-05-27', '2015-05-27') USING TTL 86400;

And yes, you are correct, it's possible to have a deleted_at column and have a sweeper that go through every matching row. It's just nicer if it's supported at db level :)

didip avatar May 21 '18 21:05 didip

Well, that's CQL. I now looked at SQL databases and I cannot find one supporting TTL.

Anyway, I see the value of this feature in certain scenarios. Some notes:

  • Adding a new USING keyword. Used by other SQL dialects, so not much of a concern.
  • Adding a new TTL keyword. This I would consider a backward incompatible change. With the vgo proposal now accepted, it can be solved, though. Alternatively, I think we can get away with not making TTL a keyword.
  • Using the USING TTL clause implies a R/W transaction must be used. That's a bit surprising when running a SELECT statement.
  • I can provide help/support/guidance to someone implementing it, but waiting for me to implement the feature may take forever.
  • Someone has to think out where the TTL data will be stored. I would go for a mandatory column TTL of type time, containing the "dead after" time. That would probably be the simplest way how to implement the feature.

WDYT?

cznic avatar May 22 '18 08:05 cznic

@didip Gentle ping.

cznic avatar Jun 02 '18 09:06 cznic