speeding up script by opening and closing DB connection just once
Hi all
I have a script which
Now this script is taking longer to execute maybe because the DB connection is opened and closed each time. My scripts is: Code:
#!/bin/ksh Code:
ACCOUNT_MISSING_FRM_RCIS_LINK-4 I think that would expedite my script. Any suggestions in this regard is appreciated!!! |
That is not possible in Bash.
You could either use another script language to achieve that (php, tcl, perl) because their API allow the use of a handle for an opened database. Bash does not. Or I think that it would also be possible to implement the loop part of the script in SQL. In MySQL it would be possible to put the list of tables in a temporary table and let MySQL loop thru it using the native macro language. Is this a script which has to run often? Is it worth, or is it just an academic excercise? jlinkels |
It may be useful to try something a little different.
Instead of querying from your input file, maybe change your shell program so that it reads each table name and writes an SQL query line into a file until you've run out of table names then execute the DBMS with that SQL file as input. Where your file would look something like Code:
select tabname, count from taba; Then your shell program would Code:
create an empty file (with > file.sql or similar) |
Quote:
Otherwise the "write the query file in bash" approach sounds interesting. |
All times are GMT -5. The time now is 05:02 PM. |