(转)Oracle查看trace文件步骤
原文地址:?http://www.2cto.com/database/201210/159305.htmlOracle查看trace文件步骤?1.获得当前trace文件生成路径SQL> select tracefile from v$process where addr in (select paddr from v$session where sid in (select sid from v$mystat));?TRACEFILE ?-------------------------------------------------------------------------------------------------------------------------------f:\oracle\administrator\diag\rdbms\orcl\orcl\trace\orcl_ora_1160.trc?2.开启当前session的traceSQL> alter session set sql_trace=true;SQL> select count(*) from t1;?3.转换trc文件内容为可读的输出结果?C:\Documents and Settings\Administrator>tkprof f:\oracle\administrator\diag\rdbms\orcl\orcl\trace\orcl_ora_1160.trc output=c:\aa.txt?TKPROF: Release 11.2.0.1.0 - Development on 星期六 10月 6 23:51:07 2012Copyright (c) 1982, 2009, Oracle and/or its affiliates. ?All rights reserved.?4.打开c:\aa.txt, 就会看到关于SQL语句 ‘ select count(*) from t1;’ 的执行计划[sql]?******************************************************************************** ?SQL ID: 5bc0v4my7dvr5 ?Plan Hash: 3724264953 ?select count(*) ?from ? ??t1 ???call ? ? count ? ? ? cpu ? ?elapsed ? ? ? disk ? ? ?query ? ?current ? ? ? ?rows ?------- ------ ?-------- ---------- ---------- ---------- ---------- ?---------- ?Parse ? ? ? ?1 ? ? ?0.00 ? ? ? 0.04 ? ? ? ? ?0 ? ? ? ? ?1 ? ? ? ? ?0 ? ? ? ? ? 0 ?Execute ? ? ?1 ? ? ?0.00 ? ? ? 0.00 ? ? ? ? ?0 ? ? ? ? ?0 ? ? ? ? ?0 ? ? ? ? ? 0 ?Fetch ? ? ? ?2 ? ? ?0.03 ? ? ? 0.01 ? ? ? ? ?0 ? ? ? 1070 ? ? ? ? ?0 ? ? ? ? ? 1 ?------- ------ ?-------- ---------- ---------- ---------- ---------- ?---------- ?total ? ? ? ?4 ? ? ?0.03 ? ? ? 0.06 ? ? ? ? ?0 ? ? ? 1071 ? ? ? ? ?0 ? ? ? ? ? 1 ???Misses in library cache during parse: 1 ?Optimizer mode: ALL_ROWS ?Parsing user id: 91 ? ???Rows ? ? Row Source Operation ?------- ?--------------------------------------------------- ?? ? ? 1 ?SORT AGGREGATE (cr=1070 pr=0 pw=0 time=0 us) ?? 72597 ? TABLE ACCESS FULL T1 (cr=1070 pr=0 pw=0 time=172543 us cost=298 size=0 card=66014) ??