Re: Asynchronous Trigger?

From: Adam Tauno Williams <awilliam(at)whitemice(dot)org>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Asynchronous Trigger?
Date: 2018-03-30 10:00:51
Message-ID: 1522404051.3217.1.camel@whitemice.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2018-03-29 at 22:29 +0000, Cory Tucker wrote:
> Is it possible to have the execution of a trigger (or any function)
> not block the completion of the statement they are associated with?
> A pattern I had hoped to implement was to do a quick update of rows
> that signaled they needed attention, and then an async per-row
> trigger would come and do the maintenance (in this case, make an
> expensive materialized view).

This is a good use of a Notification.  A trigger can queue a
notification, which can be received by a listening process - which can
then determine and do whatever is necessary.

See the "LISTEN" documentation.

--
Adam Tauno Williams <mailto:awilliam(at)whitemice(dot)org> GPG D95ED383
OpenGroupware Developer <http://www.opengroupware.us/>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Moreno Andreo 2018-03-30 13:46:50 Schema-based replication
Previous Message Achilleas Mantzios 2018-03-30 09:50:25 Re: Question about buffers_alloc in pg_stat_bgwriter view for monitoring