0

For performance testing purposes - I need to count duration of SQLPlus query. Its not so simple as it seems to be.

I have the code here:

VARIABLE RC REFCURSOR;
EXEC :RC := $aktuellesBericht;
SPOOL ${BERICHT}_${configArray[0]}.DATA
PRINT RC;
SPOOL OFF

It's just a part of the whole command. The whole command looks like this:

sqlplus -s /nolog > /dev/null 2>&1 <<EOF
CONNECT USER/PASSWORD@DATABASE
#A ton of unimportant SET and CLEAR commands goes here#
VARIABLE RC REFCURSOR;
EXEC :RC := $aktuellesBericht;
SPOOL ${BERICHT}_${configArray[0]}.DATA
PRINT RC;
SPOOL OFF
QUIT
EOF

I need to count time of EXEC :RC := $aktuellesBericht; and PRINT RC; separately. Is this even possibe? Can I count it somehow? Let me use some pseudocode showing what I want to do:

execstart = date +%s%N
EXEC :RC := $aktuellesBericht;
execend = date +%s%N

SPOOL ${BERICHT}_${configArray[0]}.DATA

printstart = date +%s%N
PRINT RC;
printend = date +%s%N
SPOOL OFF

exectime=$(( execend - execstart ))
printtime=$(( printend - printstart ))

echo $exectime;
echo $printtime;
1

1 Answer 1

0

bash has a builtin time command which executes a command then print various times :

If the time reserved word precedes a pipeline, the elapsed as well as user and system time consumed by its execution are reported when the pipeline terminates. The TIMEFORMAT variable may be set to a format string that specifies how the timing information should be displayed;

# only the real time
TIMEFORMAT="This was done in : %R seconds"

time EXEC :RC := $aktuellesBericht;
Sign up to request clarification or add additional context in comments.

1 Comment

I thought EXEC was some alias, I was misled by the bash tag and the bash-like pseudo code, sorry

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.