From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | Christophe Pettus <xof(at)thebuild(dot)com>, David Gauthier <davegauthierpg(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Best way to use trigger to email a report ? |
Date: | 2020-05-08 22:02:45 |
Message-ID: | CABUevEwMZFiGyQ86bcUeavHemT0SykSy-hscvJzFpLF4s4DRqg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, May 8, 2020 at 8:05 PM David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:
> On Fri, May 8, 2020 at 10:19 AM Christophe Pettus <xof(at)thebuild(dot)com>
> wrote:
>
>> If you don't want to periodically poll the table, you can use NOTIFY
>> within the trigger to wake up a process that is waiting on NOTIFY.
>>
>
> Kinda.
>
> "With the libpq library, the application issues LISTEN as an ordinary SQL
> command, and then must periodically call the function PQnotifies to find
> out whether any notification events have been received.".
>
> IOW, the interface for the client is still a polling interface its just
> that with LISTEN the event is transient and in-memory only (on the server)
> and thus has less overhead.
>
>
Doesn't have to be. You can use PQsocket() to get the socket back, and then
select() or poll() on that socket, and you only have to call PQnotifies()
once that call has indicated "something happened".
Similar applies to writing such daemons using for example the python or
perl interfaces. You block your process or thread on select() and take
action when that one returns.
--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>
From | Date | Subject | |
---|---|---|---|
Next Message | Tim Cross | 2020-05-08 23:14:47 | Re: Best way to use trigger to email a report ? |
Previous Message | Rob Sargent | 2020-05-08 21:57:01 | Re: Thoughts on how to avoid a massive integer update. |