DBAccess from Script...run queries concurrently
Posted in 2009
Topics: Server Administration
I run a lot of queries from unix scripts using dbaccess
dbaccess -e atb >> $LOGFILE 2>&1 <<endsql
I have some of these with a slew of queries in them that are independent of
each other and could all run at the same time, not sequentially. Is that
possible?
I am sort of doing this by spawning off multiple unix scripts, but that is a
lot of work, big pain in the butt
/u/custom/report_run_scripts/loy_flash/test/rwd_cust_pts_ltd.sh &
wait1=$!
/u/custom/report_run_scripts/loy_flash/test/loy_sls_from_rwd_ltd.sh &
wait2=$!
But this still has limitations since I can't create a script for every query
JOHN SAYRE wrote:
> I run a lot of queries from unix scripts using dbaccess
>
> dbaccess -e atb >> $LOGFILE 2>&1 <<endsql>
> I have some of these with a slew of queries in them that are independent of
> each other and could all run at the same time, not sequentially. Is that
> possible?
>
> I am sort of doing this by spawning off multiple unix scripts, but that is a
> lot of work, big pain in the butt
>
> /u/custom/report_run_scripts/loy_flash/test/rwd_cust_pts_ltd.sh &
> wait1=$!
> /u/custom/report_run_scripts/loy_flash/test/loy_sls_from_rwd_ltd.sh &
> wait2=$!
>
> But this still has limitations since I can't create a script for every query
Consider using SQSL (see sig) rather than dbaccess. The FORK function and the
the CLONE loop do exactly what you want.
--
Ciao,
Marco
______________________________________________________________________________
Marco Greco /UK /IBM Standard disclaimers apply!
Structured Query Scripting Language http://www.4glworks.com/sqsl.htm
4glworks http://www.4glworks.com
Informix on Linux http://www.4glworks.com/ifmxlinux.htm
run_sql - Execution script
********************************************************************************
***********
!#/usr/bin/ksh
for SQL in $*; do
dbaccess -e $SQL
done >>$LOGFILE 2>&1
********************************************************************************
***********
run_sql first.sql second.sql third.sql
Art
Art S. Kagel
Oninit (www.oninit.com)
IIUG Board of Directors (art@iiug.org)
Disclaimer: Please keep in mind that my own opinions are my own opinions and
do not reflect on my employer, Oninit, the IIUG, nor any other organization
with which I am associated either explicitly or implicitly. Neither do
those opinions reflect those of other individuals affiliated with any entity
with which I am affiliated nor those of the entities themselves.
On Fri, Jun 19, 2009 at 5:15 PM, JOHN SAYRE <jsayre@bebe.com> wrote:
> I run a lot of queries from unix scripts using dbaccess
>
> dbaccess -e atb >> $LOGFILE 2>&1 <<endsql>
> I have some of these with a slew of queries in them that are independent of
> each other and could all run at the same time, not sequentially. Is that
> possible?
>
> I am sort of doing this by spawning off multiple unix scripts, but that is
> a
> lot of work, big pain in the butt
>
> /u/custom/report_run_scripts/loy_flash/test/rwd_cust_pts_ltd.sh &
> wait1=$!
> /u/custom/report_run_scripts/loy_flash/test/loy_sls_from_rwd_ltd.sh &
> wait2=$!
>
> But this still has limitations since I can't create a script for every
> query
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--001636c923d7cb3a12046cbaae07
On Fri, Jun 19, 2009 at 14:15, JOHN SAYRE <jsayre@bebe.com> wrote:
> I run a lot of queries from unix scripts using dbaccess
>
> dbaccess -e atb >> $LOGFILE 2>&1 <<endsql>
> I have some of these with a slew of queries in them that are independent of
> each other and could all run at the same time, not sequentially. Is that
> possible?
>
> I am sort of doing this by spawning off multiple unix scripts, but that is
> a
> lot of work, big pain in the butt
>
> /u/custom/report_run_scripts/loy_flash/test/rwd_cust_pts_ltd.sh &
> wait1=$!
> /u/custom/report_run_scripts/loy_flash/test/loy_sls_from_rwd_ltd.sh &
> wait2=$!
>
> But this still has limitations since I can't create a script for every
> query
>
There isn't a simple way to do this. The SQLI and DRDA protocols are both
synchronous. If you want to handle N statements in parallel, you need N
separate connections to the DBMS. If these are in a single process, then
you need a separate thread for each parallel session; if these are in
multiple processes, then you end up splitting up the separate SQL scripts
anyway.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2008.0513 -- http://dbi.perl.org/
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
NB: Please do not use this email for correspondence.
I don't necessarily read it every week, even.
Fran Lebowitz<http://www.brainyquote.com/quotes/authors/f/fran_lebowitz.html>
- "Life is something to do when you can't get to sleep."
--0015174c3388a4c0a3046ce69b76
Sounds like a job for a makefile ;-)
(make -j #)
You can then even create the "dependancies" between the scripts (script z must
be run after script x etc)
On Monday 22 June 2009 03:26:58 Jonathan Leffler wrote:
> On Fri, Jun 19, 2009 at 14:15, JOHN SAYRE <jsayre@bebe.com> wrote:
> > I run a lot of queries from unix scripts using dbaccess
> >
> > dbaccess -e atb >> $LOGFILE 2>&1 <<endsql> >
> > I have some of these with a slew of queries in them that are independent
> > of each other and could all run at the same time, not sequentially. Is
> > that possible?
> >
> > I am sort of doing this by spawning off multiple unix scripts, but that
> > is a
> > lot of work, big pain in the butt
> >
> > /u/custom/report_run_scripts/loy_flash/test/rwd_cust_pts_ltd.sh &
> > wait1=$!
> > /u/custom/report_run_scripts/loy_flash/test/loy_sls_from_rwd_ltd.sh &
> > wait2=$!
> >
> > But this still has limitations since I can't create a script for every
> > query
>
> There isn't a simple way to do this. The SQLI and DRDA protocols are both
> synchronous. If you want to handle N statements in parallel, you need N
> separate connections to the DBMS. If these are in a single process, then
> you need a separate thread for each parallel session; if these are in
> multiple processes, then you end up splitting up the separate SQL scripts
> anyway.
--
Mike Aubury
http://www.aubit.com/
Aubit Computing Ltd is registered in England and Wales, Number: 3112827
Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ