Re: How to run a task continuously in the background

From: Luca Ferrari <fluca1978(at)gmail(dot)com>
To: Dirk Mika <Dirk(dot)Mika(at)mikatiming(dot)de>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to run a task continuously in the background
Date: 2019-07-15 08:49:29
Message-ID: CAKoxK+7x4wEA-AMocZ00b8pAcBe2xZMq_6s8xsKPTWq7tGPdig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jul 12, 2019 at 7:06 AM Dirk Mika <Dirk(dot)Mika(at)mikatiming(dot)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 multiple schemas on a server in which processing can be active. And processing can be started, monitored and stopped from a 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message jeanclaude marzin 2019-07-15 09:27:17 CRecordset::Open postgresql procedure call don't work
Previous Message Dirk Mika 2019-07-15 07:45:13 Re: How to run a task continuously in the background