This is my first time posting on the list. Also, I was trying to find
something on the list's history on this topic but without results.

My idea is new statement with roughly the following format (similar to update):

EXPIRE FROM my_table
    AT my_timestamp
    WHERE my_condition


EXPIRE FROM my_table
    AFTER my_interval
    WHERE my_condition

The rows that match the `my_condition` will be deleted when the
current timestamp reaches my_timestamp or, in the second case, exactly
my_interval time after the execution.

One concern would of course be the FK integrity, but the regular
DELETE takes into account the RESTRICT / SET NULL / SET DEFAULT /
CASCADE specification on the FK, so this statement would take those
into account as well.

As a consequence, a row function ttl(), i.e. time-to-live, would be
appropriate (not quite clear about this, though). Basically, would
return an interval until the deletion of the row takes place, or none
if the there's no expiration scheduled.

I know for example that redis has this feature, the EXPIRE / EXPIREAT
/ TTL commands.

Kind regards,
Blagoj Petrushev

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to