PLSQL_PROFILER

来源:互联网 发布:看图片的软件 编辑:程序博客网 时间:2024/05/19 02:41

  方便程序的调试,快速找到程序里最耗费时间的部分,从而定位程序的瓶颈


1.用sys用户执行@?/rdbms/admin/profload.sql装在PLSQL Profiler包


2.创建profiler用户

create user profiler identified by profiler default tablespace LMIS quota unlimited on LMIS;


3.赋权

grant connect to profiler;
grant create sequence to profiler;


4.用profiler用户登录执行proftab.sql脚本生成plsql_profiler_runs、plsql_profiler_data、plsql_profiler_units表和一个序列plsql_profiler_runnumber用于记录性能数据,表字段含义如下图摘于剑破冰山 ORACLE开发艺术

connect profiler/profiler@lmis

@?/rdbms/admin/proftab.sql





5.给表赋权

grant select on plsql_profiler_runnumber to public;


grant select,insert,update,delete on plsql_profiler_runs to public;


grant select,insert,update,delete on plsql_profiler_units to public;


grant select,insert,update,delete on plsql_profiler_data to public;


6.测试调用过程,任何过程皆可,此处按我测试的过程为例,看着稍微复杂一点

DECLARE
  i_result BINARY_INTEGER;
  ry   VARCHAR2(20);
  dj   VARCHAR2(20);
  jg   VARCHAR2(2000);
BEGIN
  ry:='03508';
  dj:='';
  i_result :=DBMS_PROFILER.start_profiler(run_comment=>'PKG_PDA_TASK.P_CHKOBTAIN;'||SYSDATE);
  PKG_PDA_TASK.P_CHKOBTAIN(ry,dj,jg);
  i_result :=DBMS_PROFILER.stop_profiler;
END;


7.查看结果,语句如下

select u.runid,u.unit_number,u.unit_type,u.unit_owner,u.unit_name,
d.line#,d.total_occur,d.total_time,d.min_time,d.max_time
from plsql_profiler_units u
     join plsql_profiler_data d on u.runid=d.runid and u.unit_number=d.unit_number
where u.runid=2
order by u.unit_number,d.line#;


--可查看过程在哪一行,便于分析
select line ||':'||text
from all_source
where owner='LT'
AND   type='PROCEDURE'
AND   name='PKG_PDA_TASK';

0 0
原创粉丝点击