代码之家  ›  专栏  ›  技术社区  ›  Greg Reynolds

Oracle DBMS_profiler只在结果表中显示匿名

  •  4
  • Greg Reynolds  · 技术社区  · 14 年前

    我是DBMS_Profiler的新手。我看到的所有示例都使用一个简单的顶级过程来演示探查器的使用,从中获取所有行号等。我将所有代码部署到包中,并且很难让我的概要文件会话用有用的数据填充PLSQL U探查器单元。我的大部分跑步都是这样的:

    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 提示,以及其他类似的网站。

    1 回复  |  直到 14 年前
        1
  •  4
  •   Peter Lang    14 年前

    是否确定要从中检索数据的查询没有问题? 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