Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TaFGn-0006r4-0C for pgsql-sql@postgresql.org; Mon, 19 Nov 2012 00:31:25 +0000 Received: from outmail149055.authsmtp.co.uk ([62.13.149.55]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TaFGh-0005A1-So for pgsql-sql@postgresql.org; Mon, 19 Nov 2012 00:31:24 +0000 Received: from mail-c233.authsmtp.com (mail-c233.authsmtp.com [62.13.128.233]) by punt9.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id qAJ0VJVQ015836 for ; Mon, 19 Nov 2012 00:31:19 GMT Received: from ayaki.localdomain (pa49-176-1-200.pa.nsw.optusnet.com.au [49.176.1.200] (may be forged)) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/) with ESMTP id qAJ0VAbb039392 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Mon, 19 Nov 2012 00:31:15 GMT Message-ID: <50A97DCE.8020808@2ndQuadrant.com> Date: Mon, 19 Nov 2012 08:31:10 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121029 Thunderbird/16.0.2 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: organizing cron jobs in one function References: <20121117161916.GA9492@apartia.fr> <50A8C63A.5070801@2ndQuadrant.com> <20121118171111.GA2945@apartia.fr> In-Reply-To: <20121118171111.GA2945@apartia.fr> X-Enigmail-Version: 1.4.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Server-Quench: 6def4082-31e0-11e2-a49c-0025907707a1 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZeVg0b BQteCiN5VAwpPBRK HVkIKg5MOFUSTAAU KV9eBkJUK0ETX1xC QjoVBBYDHlx4Rh0q LRVTbQRfckpOVQZr WklPDFZbCgRvBwIA GBweUgZwcgdDZ38+ JDcYXhYqDhZ6dk9+ S0waFmkAZylmPDVJ VEBQdR5XcVZKYx5E P1JiBXcEMngHZnhl TldsYGhuNGxJEikH CjI2FHYnCUERETc6 RgIDGzpnFlcCQW0x KBY9Yl8aVEEXPw08 LF0qRVMfNXde X-Authentic-SMTP: 61633235383639.1021:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 49.176.1.200/2525 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201211/17 X-Sequence-Number: 36950 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