Re: organizing cron jobs in one function

From: Craig Ringer <craig(at)2ndQuadrant(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: organizing cron jobs in one function
Date: 2012-11-19 00:31:10
Message-ID: 50A97DCE.8020808@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 11/19/2012 01:11 AM, Louis-David Mitterrand wrote:
> On Sun, Nov 18, 2012 at 07:27:54PM +0800, Craig Ringer wrote:
>> On 11/18/2012 12:19 AM, Louis-David Mitterrand wrote:
>>> Hi,
>>>
>>> I'm planning to centralize all db maintenance jobs from a single
>>> pl/pgsql function called by cron every 15 minutes (highest frequency
>>> required by a list of jobs).
>> It sounds like you're effectively duplicating PgAgent.
>>
>> Why not use PgAgent instead?
> Sure, I didn't know about PgAgent.
>
> Is it still a good solution if I'm not running PgAdmin and have no plan
> doing so?
>
It looks like it'll work. The main issue is that if your jobs run
over-time, you don't really have any way to cope with that. Consider
using SELECT ... FOR UPDATE, or just doing an UPDATE ... RETURNING
instead of the SELECT.

I'd also use one procedure per job in separate transactions. That way if
your 4-hourly job runs overtime, it doesn't block your 5-minutely one.

Then again, I'd also just use PgAgent.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Louis-David Mitterrand 2012-11-19 10:09:46 Re: organizing cron jobs in one function
Previous Message Louis-David Mitterrand 2012-11-18 17:11:13 Re: organizing cron jobs in one function