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

From Dirk Mika
Subject Re: How to run a task continuously in the background
Date
Msg-id 14555705-8010-4A73-8501-EA07B285E1BA@mikatiming.de
Whole thread Raw
In response to Re: How to run a task continuously in the background  (Luca Ferrari <fluca1978@gmail.com>)
Responses Re: How to run a task continuously in the background
Re: How to run a task continuously in the background
List pgsql-general

Creating a background worker that invokes a stored procedure once per

But this is not so simple to put in place.

 

It's not really important that the job runs once a second, but that it starts immediately when I want it to.

If I start a job with pg_cron, it will not be executed until the next full minute at the earliest.

 

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.

 

The processing of the data via a job is deliberately chosen so as to separate the insertion of the data from their processing.

If a trigger were to do this, the transaction in which the data is inserted would take longer. This is not intended.

It is common for many records to be inserted in a short time, but processing takes a little time. The application that inserts the data should however not be slowed down.

 

Dirk

--
Dirk Mika
Software Developer



mika:timing GmbH
Strundepark - Kürtener Str. 11b
51465 Bergisch Gladbach
Germany

fon +49 2202 2401-1197
dirk.mika@mikatiming.de
www.mikatiming.de

AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884
Geschäftsführer: Harald Mika, Jörg Mika


 
Attachment

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Tablespace column value null on select * from pg_tables
Next
From: Luca Ferrari
Date:
Subject: Re: after restore the size of the database is increased