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 DB2E55E5-6129-4429-A7A2-93FF330378E4@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  ("Weatherby,Gerard" <gweatherby@uchc.edu>)
List pgsql-general

You will have a trigger that, once new tuples are created (or older

update and so on) issues a NOTIFY.

Somewhere (within PostgreSQL or outside it) there will be a process

that issued a LISTEN and is locked until a notify comes in. Then it

does process whatever you need to do.

As an example your trigger function will be something like

and your listening process will be something like

 

This makes your processing fully asynchronous, and with some tune

allows you to decide the start/stop/resume policy as you need/wish.

 

Besides, it is quite hard for me to get to the point where you need to

check for new data every second, and therefore why you are not

satisfied with pg_cron or stuff like that.

 

pg_cron doesn’t start the task instantly and queues subsequent runs, if the task is still running. I just need to start the task once and it should keep running until stopped / killed.

 

Maybe I'll have to rephrase it.

Suppose I have a procedure and want to start it without the client where I start the procedure waiting for it to finish. And I want the procedure to continue even if the client that started it quits.

And I want to be able to check if the procedure is still running.

 

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: "James(王旭)"
Date:
Subject: Re: Issue related with patitioned table:How can I quickly determine which child table my record is in,given a specific primary key value?
Next
From: Nicola Contu
Date:
Subject: Re: Matview size - space increased on concurrently refresh