使用TKPROF工具进行跟踪ORACLE中程序运行状况

1.生成跟踪文件
alter session set timed_statistics=true;
alter session set events '10046 trace name context forever,level 12';
Session altered.
Session altered.

2.获得跟踪文件名

select rtrim(c.value,'/')||'/'||d.instance_name||'_ora_'||ltrim(to_char(a.spid))||'.trc'
from v$process a,v$session b,v$parameter c,v$instance d
where a.addr=b.paddr
and b.audsid=sys_context('userenv','sessionid')
and c.name='user_dump_dest';

RTRIM(C.VALUE,'/')||'/'||D.INSTANCE_NAME||'_ORA_'||LTRIM(TO_CHAR(A.SPID))||'.TRC
--------------------------------------------------------------------------------
/home/oracle/admin/ora10/udump/ora10_ora_18864.trc


3.创建TKPROF报告
tkprof /home/oracle/admin/ora10/udump/ora10_ora_16424.trc /tmp/t.txt

注意 /home/oracle/admin/ora10/udump/ora10_ora_16424.trc 这个文件只能是
ORACLE 用户才能读出


4.读报告
vi /tmp/t.txt

  1. ---运行程序
  2. selectcount(*)
  3. from
  4. t
  5. 查询和执行统计
  6. 执行次数CPU时间量占用时间磁盘IO查询当前行
  7. call调用countcpuelapseddiskquerycurrentrows
  8. -----------------------------------------------------------------------
  9. Parse分析10.000.000000
  10. Execute执行10.000.000000
  11. Fetch提取20.041.6368970801
  12. -----------------------------------------------------------------------
  13. total合计40.041.6468970801
  14. Missesinlibrarycacheduringparse:1高速缓冲错误1
  15. Optimizermode:ALL_ROWS优化方式
  16. Parsinguserid:54分析用户ID
  17. RowsRowSourceOperation
  18. ----------------------------------------------------------
  19. cr为一致方式读取,显示一致读取数(逻辑I/O)pr是物理读取pw为物理写入time=(以百万分之一秒计占用时间)
  20. 1SORTAGGREGATE(cr=708pr=689pw=0time=1638784us)
  21. 51018TABLEACCESSFULLT(cr=708pr=689pw=0time=765387us)
  22. 等候时间
  23. Elapsedtimesincludewaitingonfollowingevents:
  24. EventwaitedonTimesMax.WaitTotalWaited
  25. ----------------------------------------Waited----------------------
  26. SQL*Netmessagetoclient20.000.00
  27. dbfilescatteredread510.071.60
  28. SQL*Netmessagefromclient20.000.00
  29. ********************************************************************************

你可能感兴趣的:(oracle,sql,C++,c,C#)