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 1tKFd3-007gBU-9l for pgsql-sql@arkaria.postgresql.org; Sun, 08 Dec 2024 11:39:13 +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 1tKFcy-001G7c-83 for pgsql-sql@arkaria.postgresql.org; Sun, 08 Dec 2024 11:39:09 +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 1tKFcx-001G7U-RE for pgsql-sql@lists.postgresql.org; Sun, 08 Dec 2024 11:39:09 +0000 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tKFcw-001f0z-3n for pgsql-sql@lists.postgresql.org; Sun, 08 Dec 2024 11:39:08 +0000 Received: by mail-yb1-xb30.google.com with SMTP id 3f1490d57ef6-e398484b60bso3143069276.1 for ; Sun, 08 Dec 2024 03:39:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733657944; x=1734262744; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=tPZ+TA2pK2fD0NUAM8M5fOK2o1Xor2RBk9xswXkXH4c=; b=lIQSjSj1t3A1WYizcahxDBpXq3Ra9aNPe10XoVWodwo42ovITIykGEe6iExExr+WM3 gJ5v1EjE0klBKP37pcCOEiOC2FEtj4id4V+6D7MJ/+JND+Kh0LW+Jks2ber9lnODuzH7 FIoRbfZUkrGdj5ica6hbcEhmaZ27gRFTI3g++hyjlTxRiHy+cMqFB6RBTgV/A46QN/wr bMBzplZXpiE+55OolXSEPxQcff0bc0KOUtY3MqLaFUsgHCc9jV1ykH1UwdPcu9Gr7nnx 6vh1niANLceQxRFH/Ipz4SjUI1RQStRKbNXOazecYDNNjJaVhnUX7v1vI7J48oAyoWIi QY+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733657944; x=1734262744; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tPZ+TA2pK2fD0NUAM8M5fOK2o1Xor2RBk9xswXkXH4c=; b=Uy0D2CKptAyc61AAfVVWlPyKwun/R4V0HlQxCESErxGSvIzcBtqN9pfMU5wyKqxKhg J7T0rZbUdWXsMiyivgTuGtzNWX/oEVBnwxlVDTt/7cO1L1k9Ssyr1NKeUEircykbOsB/ 8mNA6BWy8igQNEu7t5SYBBaxwn3jSP8QNwNX3I4wFfTdzob51ydUp+6/xZ9P8tdmIN+W finbwQDpOl6i7/Ll9I3+sRkyxH5HKPfCrowdSFXTUg0kfPW/jYRp6Tf8Xgn/RKmQIgj3 nTU9H2kE1SzLUjtSJGuGn7rbJO6AWjeNN+IA6A0WOxAparAm071SE4VuJmNa44ty/0Rd RUdQ== X-Gm-Message-State: AOJu0YwB1oZiJ2J/ZnCAzcNBJ6VjRQqtbrcWFQ7cdDYRaAgQua36zu5v emEfBwbCfqqoBH240VOGbEp1rKX1pcMGwkS5tPQQ97rpe2HxKCJDx+Ynhuq+BpQ6ExMNQ3ucXAV z5HBxvAf+gotK2jMTIx44aV0DwEcmMB4W X-Gm-Gg: ASbGnctKOpgqksfq2M9UXdUEJmn4Ah83ym3YoSITOdZx9vjIHX72k4DZj0pbTgo/0Iv szvUBJL1zxrLD14sd178EAKIWoHipUk4hJYKKSVhuERYutiflsVAdSPVpXW/LZY1c X-Google-Smtp-Source: AGHT+IEdtLT3DvacwdoGwjQK7CNgp+icXy22AEmVxWNy1G/AkLZNwFuevUUE8HIaljrxRw0RAJwQB+hB/aRI9RdAyhc= X-Received: by 2002:a05:6902:1582:b0:e39:80e2:48c9 with SMTP id 3f1490d57ef6-e3a0b779ea7mr8609882276.51.1733657944619; Sun, 08 Dec 2024 03:39:04 -0800 (PST) MIME-Version: 1.0 From: kunwar singh Date: Sun, 8 Dec 2024 06:38:53 -0500 Message-ID: Subject: What is the best way to do this in Postgres To: pgsql-sql@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000f3854e0628c0b10d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f3854e0628c0b10d Content-Type: text/plain; charset="UTF-8" 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 --000000000000f3854e0628c0b10d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 spawn 10 concurrent sessions each executing a comple= x stored procedure with one of the parameters being the product ID. =
Example

CALL process_product(curdat= e, region, productid=3D>1) ;
CALL process_product(= curdate, region, productid=3D>2) ;
CALL process_pr= oduct(curdate, region, productid=3D>3) ;
CALL proc= ess_product(curdate, region, productid=3D>4) ;
... =
CALL process_product(curdate, region, productid=3D>= ;10) ;


Say I get a list of product IDs by run= ning a big query

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


Additional I= nformation
=3D=3D=3D
Everytime number of product ids will change. At a given t= ime there should be no more than 10 concurrent sessions of process_product.=
I want to trigger these procedure calls once every h= our. 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 if there is a smarter way to do it in Postgres= ?



--
Cheers,
Kunwar
--000000000000f3854e0628c0b10d--