sqlplus设置autotrace的信息是从哪获得的?该如何处理
sqlplus设置autotrace的信息是从哪获得的?
我想自己写程序获取这些信息,方便批量分析sql
不知道sqlplus是怎么获取这些信息的
------解决方案--------------------
不晓得,oracle提供了方法,为么还要自己写呢。
dbms_Xplan也可以的哦。
------解决方案--------------------
先explain plan for 查询语句
再select * from table(dbms_xplan.display);
------解决方案--------------------
LZ, oracle online document说的很清楚,你可以从V$SQL_PLAN_STATISTICS_ALL获取plan
-------------------------------
DISPLAY Function
This table function displays the contents of the plan table.
我想自己写程序获取这些信息,方便批量分析sql
不知道sqlplus是怎么获取这些信息的
执行计划
----------------------------------------------------------
Plan hash value: 272002086
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------
统计信息
----------------------------------------------------------
24 recursive calls
0 db block gets
7 consistent gets
3 physical reads
0 redo size
419 bytes sent via SQL*Net to client
415 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
------解决方案--------------------
不晓得,oracle提供了方法,为么还要自己写呢。
dbms_Xplan也可以的哦。
------解决方案--------------------
先explain plan for 查询语句
再select * from table(dbms_xplan.display);
sys@ORCL1> explain plan for select * from dual;
Explained.
sys@ORCL1> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------
Plan hash value: 272002086
--------------------------------------------------------------------------
------解决方案--------------------
Id
------解决方案--------------------
Operation
------解决方案--------------------
Name
------解决方案--------------------
Rows
------解决方案--------------------
Bytes
------解决方案--------------------
Cost (%CPU)
------解决方案--------------------
Time
------解决方案--------------------
--------------------------------------------------------------------------
------解决方案--------------------
0
------解决方案--------------------
SELECT STATEMENT
------解决方案--------------------
------解决方案--------------------
1
------解决方案--------------------
2
------解决方案--------------------
2 (0)
------解决方案--------------------
00:00:01
------解决方案--------------------
------解决方案--------------------
1
------解决方案--------------------
TABLE ACCESS FULL
------解决方案--------------------
DUAL
------解决方案--------------------
1
------解决方案--------------------
2
------解决方案--------------------
2 (0)
------解决方案--------------------
00:00:01
------解决方案--------------------
--------------------------------------------------------------------------
8 rows selected.
------解决方案--------------------
LZ, oracle online document说的很清楚,你可以从V$SQL_PLAN_STATISTICS_ALL获取plan
-------------------------------
DISPLAY Function
This table function displays the contents of the plan table.