如何查看oracle trace 文件
2017-01-16 · 知道合伙人互联网行家
关注
展开全部
1.获得当前trace文件生成路径
SQL> select tracefile from v$process where addr in (select paddr from v$session where sid in (select sid from v$mystat));
1
1
TRACEFILE
f:\Oracle\administrator\diag\rdbms\orcl\orcl\trace\orcl_ora_1160.trc
1
1
2.开启当前session的trace
SQL> alter session set sql_trace=true;
SQL> select count(*) from t1;
1
2
3
1
2
3
3.转换trc文件内容为可读的输出结果
C:\Documents and Settings\Administrator>tkprof f:\oracle\administrator\diag\rdbm
s\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 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
1
2
3
4
5
1
2
3
4
5
4.打开c:\aa.txt, 就会看到关于SQL语句 ‘ select count(*) from t1;’ 的执行计划
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)
SQL> select tracefile from v$process where addr in (select paddr from v$session where sid in (select sid from v$mystat));
1
1
TRACEFILE
f:\Oracle\administrator\diag\rdbms\orcl\orcl\trace\orcl_ora_1160.trc
1
1
2.开启当前session的trace
SQL> alter session set sql_trace=true;
SQL> select count(*) from t1;
1
2
3
1
2
3
3.转换trc文件内容为可读的输出结果
C:\Documents and Settings\Administrator>tkprof f:\oracle\administrator\diag\rdbm
s\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 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
1
2
3
4
5
1
2
3
4
5
4.打开c:\aa.txt, 就会看到关于SQL语句 ‘ select count(*) from t1;’ 的执行计划
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)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询