执行计划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 ;

 

 

 

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