# Make process parallel

**URL:** <https://community.unix.com/t/make-process-parallel/352545>\
**Category:** Shell Programming and Scripting\
**Created:** [May 8, 2015, 5:04pm UTC](https://community.unix.com/t/make-process-parallel/352545 "2015-05-08T17:04:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wahi80](https://community.unix.com/letter_avatar/wahi80/32/5_5575768a8748004e209b776fc1b2916d.png) [@wahi80](https://community.unix.com/u/wahi80)\
**Post date:** [May 8, 2015, 5:04pm UTC](https://community.unix.com/t/make-process-parallel/352545/1 "2015-05-08T17:04:51Z")

</div>

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:

```nohighlight
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

```nohighlight
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.

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [May 8, 2015, 5:54pm UTC](https://community.unix.com/t/make-process-parallel/352545/2 "2015-05-08T17:54:11Z")

</div>

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.

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

```
