Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get query execution START TIME and END TIME ? Any better Approach ?

LazarDec 2 2019 — edited Dec 8 2019

Hi All,

As per my business requirement, i have close to 100s of queries to execute in a single shot in my DB.

After execution i want to know the time taken for each and every query.

So i followed the below approach. But its time consuming, in which i have to mark the START_TIME and END_TIME in before and after for all of the 100 queries.

Let me know if there is any other better approach to do.

SELECT to_char(sysdate,'DDMMYY HH24:MI:SS')START_TIME FROM DUAL;

SELECT  'SCRIPT1' "SCRIPT",COUNT(1) CNT FROM EMPLOYEES;

SELECT to_char(sysdate,'DDMMYY HH24:MI:SS')END_TIME FROM DUAL;

SELECT to_char(sysdate,'DDMMYY HH24:MI:SS')START_TIME FROM DUAL;

SELECT  'SCRIPT2' "SCRIPT",COUNT(1) CNT FROM DEPARTMENTS;

SELECT to_char(sysdate,'DDMMYY HH24:MI:SS')END_TIME FROM DUAL;

I wanted to frame a report some like this with start time and end time. A query with the below structure will help a lot.

Script No#Count(1) cntStart TimeEnd TimeElapsed Time
Script155021219 05:23:34021219 05:23:384 Seconds
Script20021219 05:23:39021219 05:23:390 Second
Script3150021219 05:23:40021219 05:24:0020 Seconds

Regards,

Lazar

021219 05:23:34

Comments
Post Details
Added on Dec 2 2019
17 comments
49,666 views