2015-08-24 16:02 GMT+02:00 Tom Lane <t...@sss.pgh.pa.us>: > Heikki Linnakangas <hlinn...@iki.fi> writes: > > On 08/24/2015 08:06 AM, Pavel Stehule wrote: > >> it works perfectly - but the line > >> xargs -P 3 -I % sh -c "psql % -q -c 'analyze pg_attribute'; echo %" > >> is little bit ugly - with some psql option it can be cleaned to > >> xargs -P3 -I % psql % -q --echo-db -c "analyze pg_attribute" | ... > >> --echo-db requires -q option > >> What are you thinking about this idea? > > > Seems like a one-tricky-pony to me. You're just as likely to need to > > print a relation name or something else, as the current database. > > Not only that, but: > > (1) there is no reason to believe that the db name and only the db name > is needed to do another connection; what about port, host, user, etc? >
I have to agree - the possibilities is much more than database name - so one option is not good idea. > > (2) this commandeers the pipe connection to transmit out-of-band data, > making it impossible to use the pipe for its natural function, viz > transmitting ordinary data from one processing step to the next. Sure, > there are use-cases where there's no such data and you can repurpose the > pipe like that, but that's an enormous limitation. > I wrote some bash or perl scripts and I don't think so described style is less readable than other. But it has one pretty advantage - paralelism without any line more, without higher complexity. Regards Pavel > > > Overall, once your pipeline gets that complicated, I'd rather write a > > little bash or perl script with for-loops and variables. > > Yeah, on the whole this seems like a band-aid to let a bad scripting > approach limp a few steps further before it collapses completely. > > > regards, tom lane >