Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: September 01, 2018 - 6:15 am UTC

Last updated: September 04, 2018 - 5:34 am UTC

Version: 12c

Viewed 1000+ times

You Asked

1)

I have a procedure with 50 select statements, when ran it is running good performance level, but after 30 days I ran the same procedure without changing anything, it is taking more than before time, there is any system crash, network band problem,..But it is taking time..how would I check it bro ?, which select statement of procedure is taking more time.

Note:-How would I get know which select statement of procedure has been taking much time in between those 50 select statements.

Please give simple example.

and Connor said...

Search this site for "intrumentation" - lots of examples of how to instrument your code.

But here's a trivial demo using timestamps to measure performance

SQL> create or replace
  2  procedure slow_proc is
  3    x int;
  4    s timestamp := systimestamp;
  5  begin
  6    select 1 into x from dual;
  7    dbms_output.put_line('This SQL took '||(systimestamp-s));
  8    s := systimestamp;
  9
 10    select count(*)  into x from dba_objects;
 11    dbms_output.put_line('This SQL took '||(systimestamp-s));
 12    s := systimestamp;
 13
 14    select count(*)  into x from dba_objects, scott.emp;
 15    dbms_output.put_line('This SQL took '||(systimestamp-s));
 16    s := systimestamp;
 17  end;
 18  /

Procedure created.

SQL> sho err
No errors.
SQL>
SQL> set serverout on
SQL> exec slow_proc
This SQL took +000000000 00:00:00.000000000
This SQL took +000000000 00:00:00.076000000
This SQL took +000000000 00:00:00.151000000

PL/SQL procedure successfully completed.


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, September 03, 2018 - 1:34 am UTC

Is Tiemstamp better for big code ?..rather than Dbms_Profiler.
Connor McDonald
September 04, 2018 - 5:34 am UTC

Hence the parts of my response:

Search this site for "intrumentation" - lots of examples of how to instrument your code.

But here's a trivial demo using timestamps to measure performance


I would not be using dbms_profiler, because its unlikely to be useful when that code moves into Production. I'd look at doing instrumentation propery (eg with Logger or similar).

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library