What is the best way to do this in Postgres

From: kunwar singh <krishsingh(dot)111(at)gmail(dot)com>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: What is the best way to do this in Postgres
Date: 2024-12-08 11:38:53
Message-ID: CAJSrDUoBN0KGdBdQKD_tjUFM2LJipefJuQ5GpQrY2iFm8Y2J3Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello Listers,
Looking for your inputs on the most efficient way to do it in Postgres.

What I want to do:
===
I want to spawn 10 concurrent sessions each executing a complex stored
procedure with one of the parameters being the product ID.
Example

CALL process_product(curdate, region, productid=>1) ;
CALL process_product(curdate, region, productid=>2) ;
CALL process_product(curdate, region, productid=>3) ;
CALL process_product(curdate, region, productid=>4) ;
...
CALL process_product(curdate, region, productid=>10) ;

Say I get a list of product IDs by running a big query

Product ID
====
1
2
3
4
..
10

Additional Information
===
Everytime number of product ids will change. At a given time there should
be no more than 10 concurrent sessions of process_product.
I want to trigger these procedure calls once every hour. For a given hour
the number of product IDs could range from 10 to 100 in total.
I am using RDS Postgres v 15.

Question
===
I know I can create a bash script or Python script , but I am wondering if
there is a smarter way to do it in Postgres?

--
Cheers,
Kunwar

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2024-12-08 15:26:43 Re: What is the best way to do this in Postgres
Previous Message Steve Midgley 2024-12-05 18:40:46 Re: Clarification Needed on PostgreSQL Version Upgrade