ITPub博客

首页 > Linux操作系统 > Linux操作系统 > tkprof使用

tkprof使用

原创 Linux操作系统 作者:amethystic 时间:2011-12-29 16:04:03 0 删除 编辑

tkprof: 格式化输出sql trace文件

一、了解tkprof用法:

[oracle@stressdb dbhome_1]$ tkprof
Usage: tkprof tracefile outputfile [explain= ] [table= ]
              [print= ] [insert= ] [sys= ] [sort= ]
  table=schema.tablename   Use 'schema.tablename' with 'explain=' option.
  explain=user/password    Connect to ORACLE and issue EXPLAIN PLAN.
  print=integer    List only the first 'integer' SQL statements.
  aggregate=yes|no
  insert=filename  List SQL statements and data inside INSERT statements.
  sys=no           TKPROF does not list SQL statements run as user SYS.
  record=filename  Record non-recursive statements found in the trace file.
  waits=yes|no     Record summary for any wait events found in the trace file.
  sort=option      Set of zero or more of the following sort options:
    prscnt  number of times parse was called
    prscpu  cpu time parsing
    prsela  elapsed time parsing
    prsdsk  number of disk reads during parse
    prsqry  number of buffers for consistent read during parse
    prscu   number of buffers for current read during parse
    prsmis  number of misses in library cache during parse
    execnt  number of execute was called
    execpu  cpu time spent executing
    exeela  elapsed time executing
    exedsk  number of disk reads during execute
    exeqry  number of buffers for consistent read during execute
    execu   number of buffers for current read during execute
    exerow  number of rows processed during execute
    exemis  number of library cache misses during execute
    fchcnt  number of times fetch was called
    fchcpu  cpu time spent fetching
    fchela  elapsed time fetching
    fchdsk  number of disk reads during fetch
    fchqry  number of buffers for consistent read during fetch
    fchcu   number of buffers for current read during fetch
    fchrow  number of rows fetched
    userid  userid of user that parsed the cursor

Example: tkprof /home/oracle/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_27186.trc ./test.txt explain=system/pwd aggregate=yes sys=no waits=yes sort=fchela

二、在会话中打开trace开关:

1. alter session set sql_trace=true;  or exec dbms_monitor.session_trace_enable;

2. select sid,serial#,status from v$session  where audsid=userenv('sessionid') and sid=(select sid from v$mystat where statistic#=1)

     exec dbms_system.set_sql_trace_in_session(sid, serial#, true);

三、找到trace文件: show parameter user_dump_dest;

四、运行tkprof: tkprof /home/oracle/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_27186.trc ./test.txt explain=system/pwd aggregate=yes sys=no waits=yes sort=fchela

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

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2011-12-29

  • 博文量
    8
  • 访问量
    5566