Re: proposal: contrib module - generic command scheduler

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: contrib module - generic command scheduler
Date: 2015-05-12 16:31:44
Message-ID: CAFj8pRBBDJdXR5zG=h6mGrpW-E3tw_wXoT3JAOiVDJ_d5yyvcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-05-12 11:27 GMT+02:00 hubert depesz lubaczewski <depesz(at)depesz(dot)com>:

> On Tue, May 12, 2015 at 09:25:50AM +0200, Pavel Stehule wrote:
> > create type scheduled_time as (second int[], minute int[], hour int[],
> dow
> > int[], month int[]);
> > (,"{1,10,20,30,40,50}",,,) .. run every 10 minutes.
> > (,"{5}",,,) .. run once per hour
> > Comments, notices?
>
> First, please note that I'm definitely not a hacker, just a user.
>
> One comment that I'd like to make, is that since we're at planning
> phase, I think it would be great to add capability to limit number of
> executions of given command.
> This would allow running things like "at" in unix - run once, at given
> time, and that's it.
>

I would not to store state on this level - so "at" should be implemented on
higher level. There is very high number of possible strategies, what can be
done with failed tasks - and I would not to open this topic. I believe with
proposed scheduler, anybody can simply implement what need in PLpgSQL with
dynamic SQL. But on second hand "run once" can be implemented with proposed
API too.

pg_create_scheduled_command('delete obsolete data', '(,,"{1}","{1}",)',
$$DO $_$
BEGIN
DELETE FROM data WHERE inserted < current_timestamp - interval '1month';
PERFORM pg_update_scheduled_command(scheduled_command_oid(),
max_workers => 0);
END $_$
$$);

Regards

Pavel

> Best regards,
>
> depesz
>
> --
> The best thing about modern society is how easy it is to avoid contact
> with it.
>
> http://depesz.com/
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2015-05-12 17:11:35 pgsql: pg_basebackup -F t now succeeds with a long symlink target
Previous Message Stephen Frost 2015-05-12 16:23:47 Re: pgbench -f and vacuum