Re: proposal: multiple psql option -c - Mailing list pgsql-hackers

From Robert Haas
Subject Re: proposal: multiple psql option -c
Date
Msg-id CA+TgmoYKTJUakhRoSO6ixo+yJyMOZwhuYuJscSkPV0YExJKvpg@mail.gmail.com
Whole thread Raw
In response to Re: proposal: multiple psql option -c  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
On Mon, Jul 27, 2015 at 2:53 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> I am trying to run parallel execution
>
> psql -At -c "select datname from pg_database" postgres | xargs -n 1 -P 3
> psql -c "select current_database()"

Put this in a shell script called run-psql:

#!/bin/bash

test $# = 0 && exit
for f in "${@:1:$(($#-1))}"; do   echo "$f" \;
done | psql "${@:$#}"

Then:

psql -At -c "select datname from pg_database" postgres | xargs -n 1 -P
3 ./run-psql "select current_database()" "vacuum" "select 1"

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: more RLS oversights
Next
From: Dean Rasheed
Date:
Subject: Re: A little RLS oversight?