Im preparing a shell script to generate analyze command and all the commands will go to a variable.
echo $analyze_query
analyze tbl1;
analyze tbl2;
analyze tbl3;
Now I want to run one by one, and Im able to achieve that by using the below command.
for $i in $analyze_query
do
psql -h host -U user -d db -c"$i"
done
But this query will close and open a new connection for every command, Is there any way that I can run the one by one but in one session?
bash
co-processes, but that is rather complicated (here is an example). I see no benefit in running those commands in a single transaction; why would you want to do that?