Re: EXPIRE as a statement

Поиск
Список
Период
Сортировка
От Stephen Frost
Тема Re: EXPIRE as a statement
Дата
Msg-id 20140504221508.GM2556@tamriel.snowman.net
обсуждение исходный текст
Ответ на EXPIRE as a statement  (Blagoj Petrushev <b.petrushev@gmail.com>)
Список pgsql-hackers
Blagoj,

* Blagoj Petrushev (b.petrushev@gmail.com) wrote:
> 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.

An in-PG version of cron has been discussed before and seems like it
would meet your need here.  It's certainly something which I would like
to see happen, most likely using the background worker infrastructure.
I don't know of anyone actively working on it though.

Your proposal does have the interesting property that it could be
implemented without a cron-like process by keeping track of the
expiration time and then just ignoring the records even if they're
there.  That could be done with a view, of course, but as you point out,
it'd need backend/core support if it's going to work for FK
relationships or similar.

> 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.

For a view-based approcah, this function could be trivially written to
go against the underlying table to return the answer.
Thanks,
    Stephen

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Blagoj Petrushev
Дата:
Сообщение: EXPIRE as a statement
Следующее
От: Neil Tiffin
Дата:
Сообщение: Re: pgaudit - an auditing extension for PostgreSQL