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 the PL/SQL Code performance/bottleneck details using the v$ views

user546710Sep 21 2019 — edited Sep 21 2019

Hi All,

  I have one package with one SP(perf_test.p1). This is calling another stand alone sp(sp_perf_tst).  I would like to know how much time it is taking for each sql. In stand alone sp, there is PL/SQL LOOP. Is it possible to get how much time it took to complete the PL/SQL LOOP.  I want to know these details using oracle V$ Views. Please find my sample package and stand alone SP code below.

PS: I am able to get the SQL stats present in perf_test.p1 by using v$sql view. But not able to find the details about stand alone sp execution stats.

--Stand alone SP

create or replace

procedure sp_Perf_tst

IS

x int;

    begin

    for i in 1..10

    loop

    x := x+i;

    end loop;

end sp_Perf_tst;

--Package Code

create or replace package perf_test is

procedure p1(a number, b number);

create or replace package body perf_test is

procedure p1(a number, b number)

IS

x int;

    begin

     select count(*)

     into   x

     from   USER_tables;

--Stand alone SP

sp_perf_tst;

   

select count(*)

     into   x

     from   ALL_tables;

for i in 1..50

loop

select count(*)

     into   x

     from   BRANDS;

end loop;

     select count(*)

     into   x

     from   USER_tables, USER_tables;

end p1;

end;

Thank you in advance.

Thanks,

Venu Gopal

This post has been answered by John Thorton on Sep 21 2019
Jump to Answer
Comments
Post Details
Added on Sep 21 2019
8 comments
211 views