我是DBMS_PROFILER的新手.我看到的所有示例都使用一个简单的顶级过程来演示探查器的使用,并从那里获取所有行号等.我在包中部署所有代码,我很难让我的配置文件会话填充plsql_profiler_units包含有用的数据.我的大多数运行看起来像这样:
RUNID RUN_COMMENT UNIT_OWNER UNIT_NAME SECS PERCEN ----- ----------- ----------- -------------- ------- ------ 5 Test <anonymous> <anonymous> .00 2.1 Profiler 5 Test <anonymous> <anonymous> .00 2.1 Profiler 5 Test <anonymous> <anonymous> .00 2.1 Profiler
我刚刚根据所有示例嵌入了对dbms_profiler.start_profiler,flush_data和stop_profiler的调用.主要区别在于我的代码在一个包中,并调用其他包.您是否需要分析调用堆栈中的每个存储过程?如果这样使这个工具有点无用!
我已经检查了http://www.dba-oracle.com/t_plsql_dbms_profiler.htm的提示,以及其他类似的网站.
解决方法
您确定从plsql_profiler_units检索数据时查询不是问题吗?
我试过这个:
Create Procedure sub_procedure As Begin dbms_output.put_line('test'); End; Create Package test_package As Procedure test; End; Create Package Body test_package As Procedure test As Begin For i In 1 .. 10 Loop If(i<=5) Then sub_procedure; End If; End Loop; End; End; Begin DBMS_PROFILER.start_profiler(SYSDATE); test_package.test; DBMS_PROFILER.stop_profiler; End;
而这个简单的查询
Select uni.unit_name,dat.line#,dat.total_occur From plsql_profiler_data dat Join plsql_profiler_units uni On ( uni.runid = dat.runid And uni.unit_number = dat.unit_number )
给我预期的结果,显示包和程序:
<anonymous> 1 0 <anonymous> 2 0 <anonymous> 3 2 <anonymous> 4 1 <anonymous> 5 0 TEST_PACKAGE 2 0 TEST_PACKAGE 3 11 TEST_PACKAGE 4 5 TEST_PACKAGE 5 6 TEST_PACKAGE 8 1 SUB_PROCEDURE 1 0 SUB_PROCEDURE 3 5 SUB_PROCEDURE 4 5