SET EXPLAIN from program without modifying code?
Posted in 2000
Topics: Server Administration, Java & JDBC Development
Hi Again,
I'm running IDS.2000 9.20.UC1 on RH6.2. I want to gather some
information
via SET EXPLAIN ON while my Java program is running. What I'd like is a
utility that I can attach to a running session and say "start monitoring
now", let the program run a bit, then turn off monitoring. The only way
I
can see to do this is by modifying my code to bracket my current
commands
with SET EXPLAIN. But I hate the idea of hard-coding a RDBMS-specific
command. Ugly! Any ideas on a cleaner way to do this? I tried writing a
shell script like:
echo "SET EXPLAIN ON" | dbaccess my_db
java my_java_program
echo "SET EXPLAIN OFF" | dbaccess my_db
But that didn't work because SET EXPLAIN is per session, and Informix
thinks
the above is three sessions! Thanks in advance.
matt
BTW, thanks for all the great help!
Have a trigger on a commonly used table call a stored procedure that turns
set explain on. When you want to turn off this profiling, recerate the SP
with set explain off.
Remember, there are SELECT triggers in 9.20+
Ray
"Matthew Cornell" <cornell@cs.umass.edu> wrote in message
news:3A087203.59310902@cs.umass.edu...
> Hi Again,
>
> I'm running IDS.2000 9.20.UC1 on RH6.2. I want to gather some
> information
> via SET EXPLAIN ON while my Java program is running. What I'd like is a
> utility that I can attach to a running session and say "start monitoring
> now", let the program run a bit, then turn off monitoring. The only way
> I
> can see to do this is by modifying my code to bracket my current
> commands
> with SET EXPLAIN. But I hate the idea of hard-coding a RDBMS-specific
> command. Ugly! Any ideas on a cleaner way to do this? I tried writing a
> shell script like:
>
> echo "SET EXPLAIN ON" | dbaccess my_db
> java my_java_program
> echo "SET EXPLAIN OFF" | dbaccess my_db
>
>
> But that didn't work because SET EXPLAIN is per session, and Informix
> thinks
> the above is three sessions! Thanks in advance.
>
> matt
>
> BTW, thanks for all the great help!
Can you set up a DatabaseUtilities class?
I'd suggest methods like:
EnableExplain( bool doEnableExplain ) {
EnableExplain = doEnableExplain ;
}
DoExplain() ...
DoExplain( bool on ) {
if( EnableExplain ) ...
}
BeginWork // handle transactions at run time - with or without logging
in the database,
// also allow psedo-nesting of transactions - if
appropriate
&c &c
Sub-class the DatabaseUtilities class for RDBMS specific commands, and use a
factory to open an appropriate run-time version.
"Matthew Cornell" <cornell@cs.umass.edu> wrote in message
news:3A087203.59310902@cs.umass.edu...
> Hi Again,
>
> I'm running IDS.2000 9.20.UC1 on RH6.2. I want to gather some
> information
> via SET EXPLAIN ON while my Java program is running. What I'd like is a
> utility that I can attach to a running session and say "start monitoring
> now", let the program run a bit, then turn off monitoring. The only way
> I
> can see to do this is by modifying my code to bracket my current
> commands
> with SET EXPLAIN. But I hate the idea of hard-coding a RDBMS-specific
> command. Ugly! Any ideas on a cleaner way to do this? I tried writing a
> shell script like:
>
> echo "SET EXPLAIN ON" | dbaccess my_db
> java my_java_program
> echo "SET EXPLAIN OFF" | dbaccess my_db
>
>
> But that didn't work because SET EXPLAIN is per session, and Informix
> thinks
> the above is three sessions! Thanks in advance.
>
> matt
>
> BTW, thanks for all the great help!