執行計劃explain for

建立存儲執行計劃的表
    sqlplus > @ ?/rdbms/admin/utlxplan.sql
   
  
    用以下語句生成某操作的執行計劃:
    explain plan for
    select * from dual;
   
    查看執行計劃
    @?/rdbms/admin/utlxpls.sql
   
    或者
    select * from table(dbms_xplan.display);
eg:
 select hash_value from v$sqlarea where sql_text like 'SELECT * FROM D%';

通過消耗資源的Sql語句的hash值,通過試圖v$sql_plan 查出他的執行計劃
select id,parent_id pid,operation,options,object_name,cost,cardinality from
v$sql_plan where hash_value= 3433334220
eg:
select id,parent_id pid,operation,options,object_name,cost,cardinality from
v$sql_plan where hash_value='2999845277';

查詢表或者索引的實際大小:
比如表有多少個數據塊,有多少條記錄
select blocks from dba_segments where owner='ZG' and segment_name ='表名字';
select  blocks  from  dba_segments  where  owner='ZG'  and  segment_name='索引名字';


查詢表或者索引的統計信息:
select  blocks,to_char(last_analyzed,'yyyymmdd  hh24:mi')  from  dba_tables  where
owner='ZG' and table_name = 'ACC_BOOK_CHG_NOTIFY_0851';
 
    BLOCKS TO_CHAR(LAST_A
---------- --------------
     12145 20080511 20:33
 
SQL>  select blevel,leaf_blocks,distinct_keys,num_rows,clustering_factor,to_char(last_analyzed,'yyyy
mmdd  hh24:mi')  from  dba_indexes  where  owner='ZG'  and  index_name  = 'ACC_BOOK_CHG_NOTIFY_851_I3';
 
    BLEVEL LEAF_BLOCKS DISTINCT_KEYS   NUM_ROWS CLUSTERING_FACTOR TO_CHAR(LAST_A
---------- ----------- ------------- ---------- ----------------- --------------
         2           3             3          3                 3 20080511 20:33

 

 

察看某表上建立的索引情況:
select index_name,column_name,column_position from dba_ind_columns where
table_owner='ZG' and table_name = 'ACC_BOOK_CHG_NOTIFY_0851' order by 1,3;


select index_name from user_indexes where TABLE_NAME='LJH';

刪除索引:
drop index in_n ;

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章