Re: Async triggers - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Async triggers
Date
Msg-id 20070323175855.GC9623@svana.org
Whole thread Raw
In response to Async triggers  (Peter <peter@greatnowhere.com>)
List pgsql-general
On Fri, Mar 23, 2007 at 07:30:17PM +0200, Peter wrote:
> Is this possible in PG somehow? Basically I need to call web service
> whenever new row is inserted in a table - the lookup takes time up to
> 10-15 seconds. Obviously I cant do this inside trigger proc as that
> would delay inserts a lot. I suppose I could do a cron job to do
> webservice lookups periodically, but that involves delay and added point
> of failure (if cron process stops working for whatever reason). Ideally
> async trigger proc would be the solution, but it seems I cant do
> asynchronous execution in PG.

Perhaps LISTEN/NOTIFY can do what you want. The problem with "async" is
that any query has to run on the context of some session. Which one?

Normally you have a queue table that queues work to be done, and
LISTEN/NOTIFY to wake up the daemon when there's something to do.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: Peter
Date:
Subject: Async triggers
Next
From: Mark
Date:
Subject: Re: question: knopixx and postgresql on flash drive