There are DBs where you can set a DTL
, so that the data will be deleted in that period of time. Let’s say, table with DTL=2 months
means that the data in that table, which is older than 2 months, will be deleted.
No, at present CrateDB does not have cron-like functionality for data retention policies. Those are meant to be managed by the user externally.
Say you want to forget about data that is older than 7 days:
delete from table_name where the_timestamp_column < now() - interval '7 days'
You can easily concoct a script to be run by cron overnight. These commands will be helpful:
1.- With crash:
crash -c 'delete from table_name where the_timestamp_column < now() - interval '7 days''
2.- With postgres client psql
, assuming CrateDB is listening on port 5433:
psql -h localhost -p 5433 -U crate -c 'delete from table_name where the_timestamp_column < now() - interval '7 days''
Alternatively, you could use partitioned tables, by time - e.g. by month, and then you could set the cronjob to delete older partitions.