Home » SQL & PL/SQL » SQL & PL/SQL » measuring execution time of queries
measuring execution time of queries [message #9149] Wed, 22 October 2003 08:22 Go to next message
catherine
Messages: 5
Registered: January 2003
Junior Member
hello

i have twenty select statements already written. i would like to measure the response time of each query on a rapid growing database over a period of time.

what would be a reliable parameter to measure? is there a predefined package or tool already existing from oracle?

any help is welcome, thanx a lot
catherine
Re: measuring execution time of queries [message #9150 is a reply to message #9149] Wed, 22 October 2003 08:55 Go to previous messageGo to next message
Thiru
Messages: 1089
Registered: May 2002
Senior Member
A number of ways..

thiru@9.2.0:SQL>set timing on
thiru@9.2.0:SQL>select count(*) from all_objects;

COUNT(*)
----------
29629

Elapsed: 00:00:10.01
-- gives you the elapsed run time.

Also you can get the cpu,elapsed time using TKPROF. This is more reliable .
Have a look at this link for setting up & using TKPROF.
The other parameters you would look here are number of parses,QUERY(consistent reads),array fetches etc..

-Thiru

Re: measuring execution time of queries [message #9152 is a reply to message #9149] Wed, 22 October 2003 10:44 Go to previous messageGo to next message
catherine
Messages: 5
Registered: January 2003
Junior Member
hello thiru
thanks for your input! if i use the set timing on, how can i save the elapsed time to a parameter and save it in a file? where does oracle store this temporary information?
(as i see it here, i will have no privileges to install tkprof nor accessing generated files on the server)

thanx again for your patience.
greets
catherine
Re: measuring execution time of queries [message #9153 is a reply to message #9152] Wed, 22 October 2003 11:41 Go to previous messageGo to next message
sverch
Messages: 582
Registered: December 2000
Senior Member
You can use Oracle supplied
dbms_utility.get_time.
Look at

http://asktom.oracle.com/pls/ask/f?p=4950:8:383290::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:6828735867901,

or search the web.
And if you care about performance you should start working with tkprof. I am sure your DBA will help you.
Re: measuring execution time of queries [message #9154 is a reply to message #9152] Wed, 22 October 2003 11:52 Go to previous messageGo to next message
Thiru
Messages: 1089
Registered: May 2002
Senior Member
You can spool in sqlplus and save those files. But if you want to store those values in a table you can use dbms_utility.get_time . It gives the time in 100ths of a sec.

a simple example)

thiru@9.2.0:SQL>variable time1 number;
thiru@9.2.0:SQL>variable time2 number;
thiru@9.2.0:SQL>exec :time1 := dbms_utility.get_time;

PL/SQL procedure successfully completed.

thiru@9.2.0:SQL>select count(*) from dual;

COUNT(*)
----------
1

thiru@9.2.0:SQL>exec :time2 := dbms_utility.get_time;

PL/SQL procedure successfully completed.

thiru@9.2.0:SQL>exec dbms_output.put_line(:time2 - :time1) ;
1218

PL/SQL procedure successfully completed.

thiru@9.2.0:SQL>create table time_t(run_id number,time1 number,time2 number);

Table created.

thiru@9.2.0:SQL>exec insert into time_t select 1,:time1,:time2 from dual;

PL/SQL procedure successfully completed.

thiru@9.2.0:SQL>select * from time_t;

RUN_ID TIME1 TIME2
---------- ---------- ----------
1 37945083 37946301

thiru@9.2.0:SQL>drop table time_t;

Table dropped.

thiru@9.2.0:SQL>create table time_t (run_id number,ela_time number);

Table created.

thiru@9.2.0:SQL>exec insert into time_t select 1,:time2 - :time1 from dual;

PL/SQL procedure successfully completed.

thiru@9.2.0:SQL>select * from time_t;

RUN_ID ELA_TIME
---------- ----------
1 1218

thiru@9.2.0:SQL>

-Thiru
Re: measuring execution time of queries [message #9156 is a reply to message #9149] Wed, 22 October 2003 12:02 Go to previous message
sql gurus
Messages: 22
Registered: May 2002
Junior Member
simply put all your queries in a file and execute it in sqlplus

set echo on
set time on
spool kk
select * from dual
/
select * from dual
/
spo off
set echo off
set time off
Previous Topic: BULK exceptions
Next Topic: Syntax to manipulate dates format
Goto Forum:
  


Current Time: Fri Apr 26 02:53:14 CDT 2024