Hello
I am asked to run around 5-6 SQL queries in a shell script and take a note of the time taken to execute each query to a file. How do I get the time taken to run the individual SQL queries
Hello
I am asked to run around 5-6 SQL queries in a shell script and take a note of the time taken to execute each query to a file. How do I get the time taken to run the individual SQL queries
$ which time
/usr/bin/time
$ cat test.sh
rm -f logfile
time_cmd="/usr/bin/time --format=%E --append --output=logfile"
echo 'Elapsed time taken, [hours:]minutes:seconds.' >> logfile
echo Running command 1 ... >> logfile
$time_cmd sleep 0
echo Running command 2 ... >> logfile
$time_cmd sleep 1
echo Running command 3 ... >> logfile
$time_cmd sleep 2
echo Running command 4 ... >> logfile
$time_cmd sleep 0
echo Running command 5 ... >> logfile
$time_cmd sleep 1
echo Running command 6 ... >> logfile
$time_cmd sleep 2
$ cat logfile
$ cat logfile
Elapsed time taken, [hours:]minutes:seconds.
Running command 1 ...
0:00.00
Running command 2 ...
0:01.00
Running command 3 ...
0:02.00
Running command 4 ...
0:00.00
Running command 5 ...
0:01.00
Running command 6 ...
0:02.00
Substitute the SQL commands for the "sleep N" commands.
Also SQL*Plus system setting: TIMI[NG]
if turned ON displays timing statistics for each SQL or PL/SQL block run.
SET TIMI ON