- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
3#
发表于 2012-3-20 14:56:35
set autotrace on: Shows the execution plan as well as statistics of the statement.
set autotrace on explain: Displays the execution plan only.
set autotrace on statistics: Displays the statistics only.
set autotrace traceonly: Displays the execution plan and the statistics (as set autotrace on does), but doesn't print a query's result.
set autotrace off: Disables all autotrace
set autotrace traceonly 是 只显示执行计划和 执行统计信息,但是不打印查询结果, 但是仍会执行语句,即在语句执行结束后 仅打印 plan 和 statistics。
set autotrace on explain 只显示执行计划,不执行语句。
set autotrace on statistics 只显示 执行统计statistics ,需要执行语句;plan 是可以不执行就生成的, statistics 只有执行了才知道!
SQL> set timing on;
SQL> set autotrace traceonly exp;
SQL> select 1 from tab$,tab$;
Elapsed: 00:00:00.01
Execution Plan
----------------------------------------------------------
Plan hash value: 1769914890
---------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 3003K| 339K (1)| 01:07:57 |
| 1 | MERGE JOIN CARTESIAN| | 3003K| 339K (1)| 01:07:57 |
| 2 | TABLE ACCESS FULL | TAB$ | 1733 | 198 (1)| 00:00:03 |
| 3 | BUFFER SORT | | 1733 | 339K (1)| 01:07:54 |
| 4 | TABLE ACCESS FULL | TAB$ | 1733 | 196 (1)| 00:00:03 |
---------------------------------------------------------------------
SQL> set autotrace traceonly statistics;
SQL> select 1 from tab$,tab$;
3003289 rows selected.
Elapsed: 00:04:03.10
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
3209 consistent gets
0 physical reads
0 redo size
51657072 bytes sent via SQL*Net to client
2202878 bytes received via SQL*Net from client
200221 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
3003289 rows processed |
|