Make process parallel

Hi,

I have a file which has a list of 200 tables e.g: table.txt
I need to do a count for each table and store it in a file.

So I did something like this:

for TABLE in `cat table.txt`
do
T_CNT=$(sqlplus -s -l / as sysdba <<EOF
set echo off heading off feadback off
SELECT count(*)
FROM ${TABLE};
exit;
EOF)

echo "$T_CNT|$TABLE >> $AUDIT_FILE
done

The above script does the job, but it goes through each table one at a time.
Is there a way to make this process more parallel, so that I can query multiple tables at a time?

I was thinking of doing a split. Something like

split -l 20 table.txt

The above line would create 10 splits, so I could query 10 tables at a time.

But I'm not sure what my next step is so that 10 Select clauses are issued at smae time.

Please advise.

I bet you'd get much better speedup by connecting to the database once instead of 200 times, and accomplish this without DDOS-ing your database server.

awk 'BEGIN { print "set head off;" } { print "SELECT CONCAT(CONCAT(\""$1"\", \"|\"), COUNT(*)) FROM "$1";" }' tables.txt | sqlplus -s -l / as sysdba > $AUDIT_FILE