oracle sql执行计划autotrace 安装

 

        小生对oracle了解不多,平时也仅是简单的应用。写的sql多了,问题也就多,经常闹得DBA很蛋疼。网上搜罗了一下,oracle10 有个explain 工具,autotrace开启后,sqlplus里 执行sql就可以看到执行计划分析,这个可以帮助自己做个简单的sql性能分析。

     

    
SQL> connect sys/sys as sysdba;
SQL> @/opt/oracle/product/10.2/db_1/sqlplus/admin/plustrce.sql;
SQL> create public synonym plan_table_explain for plan_table;--建立同义词
SQL> grant all on plan_table_explain to public;--授权所有用户
SQL>@/opt/oracle/product/10.2/db_1/sqlplus/admin/plustrce.sql;
SQL>grant plustrace to public;
SQL>set autotrace on;---开启autotrace
SQL> set timing on;--显示执行时间

SQL>spool d:\test.txt;
SQL> select * from nm_sp_type ;

    TYPEID TYPENAME                                                                                
---------- --------------------                                                                    
         1 内部                                                                                    
         2 外部                                                                                    
         3 测试                                                                                    


执行计划
----------------------------------------------------------                                         
Plan hash value: 688850876                                                                         
                                                                                                   
--------------------------------------------------------------------------------                   
| Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |                   
--------------------------------------------------------------------------------                   
|   0 | SELECT STATEMENT  |            |     3 |    24 |     3   (0)| 00:00:01 |                   
|   1 |  TABLE ACCESS FULL| NM_SP_TYPE |     3 |    24 |     3   (0)| 00:00:01 |                   
--------------------------------------------------------------------------------                   


统计信息
----------------------------------------------------------                                         
          0  recursive calls                                                                       
          0  db block gets                                                                         
          8  consistent gets                                                                       
          0  physical reads                                                                        
          0  redo size                                                                             
        450  bytes sent via SQL*Net to client                                                      
        338  bytes received via SQL*Net from client                                                
          2  SQL*Net roundtrips to/from client                                                     
          0  sorts (memory)                                                                        
          0  sorts (disk)                                                                          
          3  rows processed                                                                        

SQL> select * from nm_sp_type where typeid = 0 ;

未选定行


执行计划
----------------------------------------------------------                                         
Plan hash value: 4154109726                                                                        
                                                                                                   
--------------------------------------------------------------------------------------------       
| Id  | Operation                   | Name         | Rows  | Bytes | Cost (%CPU)| Time     |       
--------------------------------------------------------------------------------------------       
|   0 | SELECT STATEMENT            |              |     1 |     8 |     1   (0)| 00:00:01 |       
|   1 |  TABLE ACCESS BY INDEX ROWID| NM_SP_TYPE   |     1 |     8 |     1   (0)| 00:00:01 |       
|*  2 |   INDEX UNIQUE SCAN         | SYS_C0019321 |     1 |       |     0   (0)| 00:00:01 |       
--------------------------------------------------------------------------------------------       
                                                                                                   
Predicate Information (identified by operation id):                                                
---------------------------------------------------                                                
                                                                                                   
   2 - access("TYPEID"=0)                                                                          


统计信息
----------------------------------------------------------                                         
          0  recursive calls                                                                       
          0  db block gets                                                                         
          1  consistent gets                                                                       
          0  physical reads                                                                        
          0  redo size                                                                             
        295  bytes sent via SQL*Net to client                                                      
        327  bytes received via SQL*Net from client                                                
          1  SQL*Net roundtrips to/from client                                                     
          0  sorts (memory)                                                                        
          0  sorts (disk)                                                                          
          0  rows processed                                                                        

SQL> spool off ;---关闭保存

SQL>set autotrace off ;---关闭自动计划跟踪

结果分析稍后补上

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值