From: Sim Zacks <sim@compulab.co.il>
To: pgsql-general@postgresql.org
Subject: Re: Asynchronous trigger
Date: Thu, 07 Sep 2006 13:47:53 +0200
Message-ID: <edotit$gu$1@news.hub.org> (raw)
In-Reply-To: <44FF3DAE.5050406@praud.com>
References: <44FF3DAE.5050406@praud.com>
You want to use the Notify/Listen framework.
1) You need a rule on a table that says on Update (or insert or delete)
do also notify {key}
2) You need a daemon running against the server that calls listen {key}
3) when the table is updated (or inserted or deleted) then your
application will be able to check the table and see what needs to be done.
I just did this for a process that needs to update a denormalized
statistics table every time the data changes and it seems to be working
great. My query takes 2.5 seconds and the users didn't want to wait that
long each time they modified a record. They also refused to tolerate it
being updated every 10 minutes. They wanted it in as close to real time
as it could be (with good reason, i might add). So the daemon calls a
function and it works just fine.
Sim
Jean-Christophe Praud wrote:
> Hi all,
>
> I'm planning to convert an application to postgresql 8.1 (from mysql).
> Currently we have some recursive procedures done on the application side
> we would want to rewrite as stored pl/pgsql procedures called by
> triggers...
>
> Is it possible for these triggers to be asynchronous, in order not to
> block the client application during the recursive process ?
>
> Regards,
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: sim@compulab.co.il
Subject: Re: Asynchronous trigger
In-Reply-To: <edotit$gu$1@news.hub.org>
References: <44FF3DAE.5050406@praud.com> <edotit$gu$1@news.hub.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox