1、查看表空间碎片的方法spa
1.查看fsfi值table
select a.tablespace_name,select
trunc(sqrt(max(blocks)/sum(blocks))* (100/sqrt(sqrt(count(blocks)))),2) fsfi 方法
from dba_free_space a,dba_tablespaces bdb
where a.tablespace_name=b.tablespace_nametab
and b.contents not in('TEMPORARY','UNDO','SYSAUX')文件
group by A.tablespace_name vi
order by fsfi; dba
若是FSFI小于<30则表空间碎片太多.co
fsfi的最大可能值为100(一个理想的单文件表空间)。随着范围的增长,fsfi值缓慢降低,而随着最大范围尺寸的减小,fsfi值会迅速降低。
2.查看dba_free_space
dba_free_space 显示的是有free 空间的tablespace ,若是一个tablespace 的free 空间不连续,
那每段free空间都会在dba_free_space中存在一条记录。若是一个tablespace 有好几条记录,
说明表空间存在碎片,当采用字典管理的表空间碎片超过500就须要对表空间进行碎片整理。
select a.tablespace_name ,count(1) 碎片量 from
dba_free_space a, dba_tablespaces b
where a.tablespace_name =b.tablespace_name
and b.contents not in('TEMPORARY','UNDO','SYSAUX')
group by a.tablespace_name
having count(1) >20
order by 2;
2、整理方法
alter tablespace 表空间名 coalesce;
若是再次查看碎片没有减小,则需考虑重建表空间。