Subject: xargs psql

From: Shaozhong SHI <[email-masked]>
Date: Thu, 28 Apr 2022 12:32:42 +0100

Running lots of postgres commands in parallel | Mark's blog
(markandruth.co.uk)
<https://markandruth.co.uk/2016/05/26/running-lots-of-postgres-commands-in-parallel>

Has anyone made success with this?

How to put xargs command line correctly?

Regards,

David

---

From: Marc Mamin <[email-masked]>
Date: Thu, 28 Apr 2022 13:10:02 +0000

Hello , it works for me.
 I remember some difficulties with quote escaping. That's while  I'm using $$ quoting for the sql aguments.

here is how ma commands look like:

psqlexec="psql -h$pghost -p$pgport -U$pguser -d${pgdb} -1 -P  format=u -tqX";

$psqlexec -c "SELECT relname FROM pg_class WHERE ..." \
| xargs -n 1 -P 8 -I{} bash -c "$psqlexec -c 'select * from foo(\$\${}\$\$)' > ouputdir/{}.out"

HTH,

Marc Mamin
________________________________________
Von: Shaozhong SHI <[email-masked]>
Gesendet: Donnerstag, 28. April 2022 13:32:42
An: pgsql-sql
Betreff: xargs psql

Running lots of postgres commands in parallel | Mark's blog (markandruth.co.uk)<https://markandruth.co.uk/2016/05/26/running-lots-of-postgres-commands-in-parallel>

Regards,

David

---

From: Rob Sargent <[email-masked]>
Date: Thu, 28 Apr 2022 06:59:58 -0700

> On Apr 28, 2022, at 6:10 AM, Marc Mamin <[email-masked]> wrote:
> 
> Hello , it works for me.
You might be better off with gnu parallel

---

From: Shaozhong SHI <[email-masked]>
Date: Thu, 28 Apr 2022 15:05:07 +0100

Some suggested using no_hup.   Would that work?

Regards,

David

On Thu, 28 Apr 2022 at 15:00, Rob Sargent <[email-masked]> wrote:

> > Running lots of postgres commands in parallel | Mark's blog (
> markandruth.co.uk)<
> https://markandruth.co.uk/2016/05/26/running-lots-of-postgres-commands-in-parallel
> >
> >

---

From: Rob Sargent <[email-masked]>
Date: Thu, 28 Apr 2022 07:53:51 -0700

> On Apr 28, 2022, at 7:05 AM, Shaozhong SHI <[email-masked]> wrote:
> 
No not like gnu parallel.