oracle巡检

来源:互联网 发布:为什么淘宝打不开了 编辑:程序博客网 时间:2024/05/02 06:13
检查表和索引的统计信息是否太旧:
表:
select * from user_tables order by last_analyzed;
select * from user_tab_partitions order by last_analyzed;
索引:
select * from user_indexes order by last_analyzed;
select * from user_ind_partitions order by last_analyzed;
---------检查表空间的碎片程度(DML)
select df.tablespace_name "Tablespace",
       df.bytes / (1024 * 1024) "Total Size",
       sum(fs.bytes) / (1024 * 1024) "Free Size",
       round(sum(fs.bytes) * 100 / df.bytes) "Pct Free",
       round((df.bytes - sum(fs.bytes)) * 100 / df.bytes) "Pct Used",
       ROUND(100 * SQRT(MAX(fs.bytes) / SUM(fs.bytes)) *
             (1 / SQRT(SQRT(COUNT(fs.bytes)))),
             2) FSFI
  from dba_free_space fs,
       (select tablespace_name, sum(bytes) bytes
          from dba_data_files
         group by tablespace_name) df
 where fs.tablespace_name = df.tablespace_name
 group by df.tablespace_name, df.bytes;
原创粉丝点击