首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

sqlplus设立autotrace的信息是从哪获得的

2013-10-10 
sqlplus设置autotrace的信息是从哪获得的?我想自己写程序获取这些信息,方便批量分析sql不知道sqlplus是怎

sqlplus设置autotrace的信息是从哪获得的?
我想自己写程序获取这些信息,方便批量分析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.
In addition, you can use this table function to display any plan (with or without statistics) stored in a table as long as the columns of this table are named the same as columns of the plan table (or V$SQL_PLAN_STATISTICS_ALL if statistics are included). You can apply a predicate on the specified table to select rows of the plan to display.

-----------------------------
举个例子:select * from dual;

1.用autotarce:
SQL> set autot traceonly;
SQL> select * from dual;


Execution Plan
----------------------
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 
[解决办法]

--------------------------------------

2.通过V$SQL_PLAN_STATISTICS_ALL查询:

SQL> select sql_id,sql_text from v$sql where sql_text like 'select * from dual%';



SQL_ID
-------------
SQL_TEXT
--------------------------------------------
a5ks9fhw2v9s1
select * from dual

SQL> select sql_id,OPERATION,options from V$SQL_PLAN_STATISTICS_ALL
where sql_id='a5ks9fhw2v9s1';  2


SQL_ID        OPERATION                      OPTIONS
------------- ------------------------------ ------------------------------
a5ks9fhw2v9s1 SELECT STATEMENT
a5ks9fhw2v9s1 TABLE ACCESS                   FULL


热点排行
Bad Request.