Skip to content
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.

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

Open
didip opened this issue May 17, 2018 · 4 comments
Open

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

didip opened this issue May 17, 2018 · 4 comments

Comments

@didip
Copy link

didip commented May 17, 2018

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.

@cznic
Copy link
Owner

cznic commented May 18, 2018

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.

@didip
Copy link
Author

didip commented May 21, 2018

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 :)

@cznic
Copy link
Owner

cznic commented May 22, 2018

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
Copy link
Owner

cznic commented Jun 2, 2018

@didip Gentle ping.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants