PL/SQL Profiler 和SQL Developer 报表

执行PLSQL数据库需要:
 1. 以SYS用户执行$ORACLE_HOME/rdbms/admin/profload.sql, 创建dbms_profiler包
2. 当前schema(以scott为例)执行$ORACLE_HOME/rdbms/admin/proftab.sql创建profiler需要的表和sequence. 注意:这些都是普通的表。一般鼓励每个schema创建自己的profiler表,以免混淆。
3. grant execute on dbms_profiler to scott.

使用SQL profiler例子:
begin
       dbms_profiler.start_profiler ('Performance');     
       pls; --procedure to be profiled.
       dbms_profiler.stop_profiler ();
end;

创建sql developer报表找出耗时最长的十行代码:
1. 运行SQL Developer, View --&gt Reports --&gt User Defined Reports --&gt New Reports 
2. 填入报表名,在Query里贴入:
select * from (
select to_char(run.run_date, 'yyyy/mm/dd hh24:mi:ss') run_date, substr(run_comment, 1,20) run_comment, unit.unit_name object_name, 
dat.line#,substr(src.text, 1, 30) source_code, dat.total_occur, to_char(dat.total_time/1000000000, '9990.999') total_time, to_char(dat.min_time/1000000000, '9990.999') min_time, to_char(dat.max_time/1000000000, '9990.999') max_time
from plsql_profiler_runs run, plsql_profiler_units unit, plsql_profiler_data dat, all_source src
where
dat.line#=src.line and
unit.unit_name=src.name and
unit.unit_owner=src.owner and
run_comment =:run_comment and 
run.runid=unit.runid
and unit.runid=dat.runid 
and unit.unit_number=dat.unit_number
and unit.unit_name<>''
order by dat.total_time desc) 
where rownum <= 10;
3. 点击确定后保存报表。每次运行报表时,需要填入Comment作为绑定变量传入。注意大小写。每次运行plsql profiler,用不同comment以示区别。

在$ORACLE_HOME/rdbms/admin下
profdemo.sql
profsum.sql
profrep.sql
作为参考。可以创建自己的报表。



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/638844/viewspace-769683/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/638844/viewspace-769683/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值