Re: Async triggers

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Peter <peter(at)greatnowhere(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Async triggers
Date: 2007-03-23 17:58:55
Message-ID: 20070323175855.GC9623@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ottavio Campana 2007-03-23 18:40:58 concurrency in stored procedures
Previous Message MargaretGillon 2007-03-23 17:32:28 Re: shell script to SQL statement: `pg_dump | psql -U`