Re: running maintenance tasks on DB

From: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: running maintenance tasks on DB
Date: 2000-09-23 16:45:02
Message-ID: 20000923124502.A5141@klamath.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Sep 23, 2000 at 05:26:47PM +0200, Louis-David Mitterrand wrote:
> Approaching completion of an online auction system based on Postgres and
> mod_perl/Apache I yet have to devise a good way of running certain
> maintenance tasks on the DB like closing auctions, notifying winners,
> transferring old records to archive tables, etc.
>
> What is the usual way of programming such tasks? Write a backend
> function (in pl/sql or C) and call it from a cron job? From a mod_perl
> handler?

I don't know if this is the best way, but I usually just write a Perl
script and run it through cron. You just have to make sure that you
maintain data integrity while doing maintainence - i.e. there is no
point where the data is invalid. This usually means putting stuff
into transactions, but that's no big deal.

I don't believe you can get backend functions to run at certain
times, without using a mechanism like cron to connect to the DB and
run them.

A mod_perl handler is a totally different matter. That's for doing
stuff with HTTP requests - isn't this unrelated? I would think that
you'd have mod_perl handlers displaying your content and manipulating
the DB, and have some scripts set to run every X minutes/hours which
do maintainence.

I use Perl, but you can obviously use any language you like, provided
it has a Postgres interface.

HTH,

Neil

--
Neil Conway <neilconway(at)home(dot)com>
Get my GnuPG key from: http://klamath.dyndns.org/mykey.asc
Encrypted mail welcomed

In the beginning the Universe was created. This has made a lot of people
very angry and been widely regarded as a bad move.
-- Douglas Adams

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jarmo Paavilainen 2000-09-23 17:11:31 Idea to a replication solution (warning: long, boring, OT? and possibly stupid)
Previous Message Tom Lane 2000-09-23 16:20:07 Re: [SQL] how to store a query, that results in a table