SQL> set autotrace
用法: SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]
--用法1:查看执行计划、统计信息并且返回sql结果集
set autotrace on;
select count(*) from t;
COUNT(*)
----------
50295
已用时间: 00: 00: 00.01
执行计划
----------------------------------------------------------
Plan hash value: 2966233522
-------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 159 (2)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| T | 50295 | 159 (2)| 00:00:02 |
-------------------------------------------------------------------
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
509 bytes sent via SQL*Net to client
211 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed
---方法2:查看执行计划、统计信息不返回sql结果集:
SQL> set autotrace traceonly;
SQL> select * from t2;
已选择402344行。
执行计划
----------------------------------------------------------
Plan hash value: 1513984157
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 402K| 33M| 1240 (3)| 00:00:15 |
| 1 | TABLE ACCESS FULL| T2 | 402K| 33M| 1240 (3)| 00:00:15 |
--------------------------------------------------------------------------
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
911 bytes sent via SQL*Net to client
190 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
402344 rows processed
---方法3:只看执行计划不返回sql结果集:
QL> set autotrace traceonly explain;
SQL> select * from t;
已用时间: 00: 00: 00.01
执行计划
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 50295 | 4273K| 161 (3)| 00:00:02 |
| 1 | TABLE ACCESS FULL| T | 50295 | 4273K| 161 (3)| 00:00:02 |
---方法4:只看统计信息不返回sql结果集:
SQL> set autotrace traceonly statistics;
SQL> select * from t;
已选择50295行。
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
911 bytes sent via SQL*Net to client
189 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
50295 rows processed
用法: SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]
--用法1:查看执行计划、统计信息并且返回sql结果集
set autotrace on;
select count(*) from t;
COUNT(*)
----------
50295
已用时间: 00: 00: 00.01
执行计划
----------------------------------------------------------
Plan hash value: 2966233522
-------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 159 (2)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| T | 50295 | 159 (2)| 00:00:02 |
-------------------------------------------------------------------
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
509 bytes sent via SQL*Net to client
211 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed
---方法2:查看执行计划、统计信息不返回sql结果集:
SQL> set autotrace traceonly;
SQL> select * from t2;
已选择402344行。
执行计划
----------------------------------------------------------
Plan hash value: 1513984157
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 402K| 33M| 1240 (3)| 00:00:15 |
| 1 | TABLE ACCESS FULL| T2 | 402K| 33M| 1240 (3)| 00:00:15 |
--------------------------------------------------------------------------
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
911 bytes sent via SQL*Net to client
190 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
402344 rows processed
---方法3:只看执行计划不返回sql结果集:
QL> set autotrace traceonly explain;
SQL> select * from t;
已用时间: 00: 00: 00.01
执行计划
----------------------------------------------------------
Plan hash value: 1601196873
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 50295 | 4273K| 161 (3)| 00:00:02 |
| 1 | TABLE ACCESS FULL| T | 50295 | 4273K| 161 (3)| 00:00:02 |
---方法4:只看统计信息不返回sql结果集:
SQL> set autotrace traceonly statistics;
SQL> select * from t;
已选择50295行。
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
911 bytes sent via SQL*Net to client
189 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
50295 rows processed