Re: How to run a task continuously in the background - Mailing list pgsql-general

From Luca Ferrari
Subject Re: How to run a task continuously in the background
Date
Msg-id CAKoxK+7x4wEA-AMocZ00b8pAcBe2xZMq_6s8xsKPTWq7tGPdig@mail.gmail.com
Whole thread Raw
In response to Re: How to run a task continuously in the background  (Dirk Mika <Dirk.Mika@mikatiming.de>)
Responses Re: How to run a task continuously in the background
List pgsql-general
On Fri, Jul 12, 2019 at 7:06 AM Dirk Mika <Dirk.Mika@mikatiming.de> wrote:
>
>
>
> A cron job will only run once a minute, not wake up every second.
>
>
>
> I would like to avoid external programs if possible. In the current Oracle environment, there are potentially
multipleschemas on a server in which processing can be active. And processing can be started, monitored and stopped
froma client application. And only for the schema with which the application is connected. 
>

Creating a background worker that invokes a stored procedure once per
second? <https://www.postgresql.org/docs/11/bgworker.html>
But this is not so simple to put in place.

Otherwise pg_cron with a function that performs a pg_sleep of one
second in a loop.

Anyway, it seems to me you are better refactoring your solution: it
seems you need to process data when _new data_ comes, not once per
second, so it sounds to me like a trigger could solve the problem.

Luca



pgsql-general by date:

Previous
From: Dirk Mika
Date:
Subject: Re: How to run a task continuously in the background
Next
From: jeanclaude marzin
Date:
Subject: CRecordset::Open postgresql procedure call don't work