views:

106

answers:

2

I am trying to track performance on some procedures that run too slow (and seem to keep getting slower). I am using v$session_longops to track how much work has been done, and I have a query (sofar/((v$session_longops.LAST_UPDATE_TIME-v$session_longops.start_time)*24*60*60)) that tells me the rate at which work is being done.

What I'd like to be able to do is capture the rate at which work is being done and how it changes over time. Right now, I just re-execute the query manually, and then copy/paste to Excel. Not very optimal, especially when the phone rings or something else happens to interrupt my sampling frequency.

Is there a way to have script in SQL*Plus run a query evern n seconds, spool the results to a file, and then continue doing this until the job ends?

(Oracle 10g)

+1  A: 

If you can live with running PL/SQL instead of a SQL*Plus script, you could consider using the Oracle Scheduler. See chapters 26, 27, and 28 of the Oracle Database Administrator's Guide.

Vadim K.
+3  A: 

Tanel Poder's snapper script does a wonderful job of actively monitoring performance. It has parameters for

<seconds_in_snap> - the number of seconds between taking snapshots
<snapshot_count>  - the number of snapshots to take ( maximum value is power(2,31)-1 )

It uses PL/SQL and a call to DBMS_LOCK.SLEEP

Gary
I'm not sure I have access to the scheduler, so I'll give this a look. Thanks1
FrustratedWithFormsDesigner
Looked at the script, nice! +1
Vadim K.
I haven't had a chance to run this yet, but the DBA really likes it and plans to do something with it, so I think this is the answer!
FrustratedWithFormsDesigner