AW: xargs psql

From: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
To: Shaozhong SHI <shishaozhong(at)gmail(dot)com>, pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: AW: xargs psql
Date: 2022-04-28 13:10:02
Message-ID: e4456218b6a94aada98534b538429f48@intershop.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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 <shishaozhong(at)gmail(dot)com>
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>

Has anyone made success with this?

How to put xargs command line correctly?

Regards,

David

In response to

  • xargs psql at 2022-04-28 11:32:42 from Shaozhong SHI

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rob Sargent 2022-04-28 13:59:58 Re: xargs psql
Previous Message Shaozhong SHI 2022-04-28 11:32:42 xargs psql