Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tKKkI-00864M-U9 for pgsql-sql@arkaria.postgresql.org; Sun, 08 Dec 2024 17:07:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tKKkF-001udX-Ts for pgsql-sql@arkaria.postgresql.org; Sun, 08 Dec 2024 17:07:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tKKkF-001udN-FP for pgsql-sql@lists.postgresql.org; Sun, 08 Dec 2024 17:07:00 +0000 Received: from mail-vs1-xe2d.google.com ([2607:f8b0:4864:20::e2d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tKKk9-001hE0-7B for pgsql-sql@lists.postgresql.org; Sun, 08 Dec 2024 17:06:59 +0000 Received: by mail-vs1-xe2d.google.com with SMTP id ada2fe7eead31-4afde39e360so409047137.0 for ; Sun, 08 Dec 2024 09:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heimdalldata.com; s=google; t=1733677612; x=1734282412; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WM5c+Tr3AM4RlTsw9uIYFKIolK5in81jT7jj2RmZALY=; b=u45ywn9z99sMPrrsi7veBm3or2sG0O8ytN8dcK5L1ysjm5LEslp57mLJxxUlyjZpPu rTJdNRqUMCj3PHlmHSI54mY3EQns/6Nbg+7EeA+MiXcNn5g6iBdHlnLIDWPMko9FoCp4 IjbK2nGjRcrNPGnWRe2ask5DU+89Qui8zcjBI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733677612; x=1734282412; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WM5c+Tr3AM4RlTsw9uIYFKIolK5in81jT7jj2RmZALY=; b=G6qWTso0C7fjSt7maUWvGj28N3eYO1T1LkCvCCPNZq+kxV+RWJPEhsEEu3d4mM4ScB AnTFlMMjIKwMQoyT9+2vV3FbQoEuw1j44ggf9oSgfKXjel3RrNZtOFF6Uoxe2vI9RV5V p23uK8AhNjIiDtmSc0WOi9GoSbeWxOrvnFgNISjf58x5qiJfKUKUZkfD2mBX+ZhAVV4P gtG37PDDMwax/nbLzRm02kHOBkS+eJSSsMHNOxA9vosSU8hqKNFYSHdy2aN+uMq2wcwE 66IbPUmeaMoCYHFmkPhTzPJ5CfJmn2DsEz7Rf6X2xoA3TVQaMsSy5XMfMR+y/t/BTBeq bmzA== X-Gm-Message-State: AOJu0Yyj8HkSQgitzjzlL0s+vKNZlE5UZh3weCiEyF4tiroPYKBZk/O/ WZGeAD+NyYW/dlqz38W2cPdzO+L1sdzGzbIYQemSK+gxdaTp44T/LKIqlHK/yW2imT55ZxFJ8Wm FfOR2Sp52Gke3KrHTDjG459zvRxv8RJUmZENQMA== X-Gm-Gg: ASbGncsr5GbALpr1RVmwvS96R8QGSHrsx4sjULTXPkmig3+MVoz/AUXNsZbiqklUzMQ NbQHp/byTfzmSXShGVNGubib8m/6gIrs= X-Google-Smtp-Source: AGHT+IHTIb+EbdLy+dpdBHWTMtzgYYNbOG7kqoYwXJpeQjBDPLcwyaloqV1fNn+uXVlo7j14G07+dgaVRQf/5AsIZ7I= X-Received: by 2002:a05:6102:440f:b0:4af:5e86:3ff9 with SMTP id ada2fe7eead31-4afcaa1b35dmr9517669137.8.1733677612026; Sun, 08 Dec 2024 09:06:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Erik Brandsberg Date: Sun, 8 Dec 2024 12:06:43 -0500 Message-ID: Subject: Re: What is the best way to do this in Postgres To: kunwar singh Cc: pgsql-sql Content-Type: multipart/alternative; boundary="000000000000386bf40628c546f0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000386bf40628c546f0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Check the extension ph_cron, while I have never used it, it may be good to use as part of the solution. On Sun, Dec 8, 2024, 6:39=E2=80=AFAM kunwar singh wrote: > Hello Listers, > Looking for your inputs on the most efficient way to do it in Postgres. > > What I want to do: > =3D=3D=3D > 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=3D>1) ; > CALL process_product(curdate, region, productid=3D>2) ; > CALL process_product(curdate, region, productid=3D>3) ; > CALL process_product(curdate, region, productid=3D>4) ; > ... > CALL process_product(curdate, region, productid=3D>10) ; > > > Say I get a list of product IDs by running a big query > > Product ID > =3D=3D=3D=3D > 1 > 2 > 3 > 4 > .. > 10 > > > Additional Information > =3D=3D=3D > 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 > =3D=3D=3D > I know I can create a bash script or Python script , but I am wondering i= f > there is a smarter way to do it in Postgres? > > > > -- > Cheers, > Kunwar > --000000000000386bf40628c546f0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Check the extension ph_cron, while I have never used it, = it may be good to use as part of the solution.

On Sun, Dec 8, 2024, 6:39=E2= =80=AFAM kunwar singh <krish= singh.111@gmail.com> wrote:
=
Hello Listers,
Looking for=C2=A0your inputs= on the most efficient way to do it in Postgres.=C2=A0

=
What I want to do:=
=3D=3D=3D
I want to spa= wn 10 concurrent sessions each executing a complex stored procedure with on= e of the parameters being the product ID.
Example

= CALL process_product(curdate, region, productid=3D>1) ;
CALL = process_product(curdate, region, productid=3D>2) ;
CALL proce= ss_product(curdate, region, productid=3D>3) ;
CALL process_pr= oduct(curdate, region, productid=3D>4) ;
...
CALL p= rocess_product(curdate, region, productid=3D>10) ;


=
Sa= y I get a list of product IDs by running a big query

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


= Additional Information
=3D=3D=3D
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 hou= r the number of product IDs could range from 10 to 100 in total.
I am using RDS Postgres v 15.

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



--
Cheers,
Kunwar
--000000000000386bf40628c546f0--