Oracle 查询表空间占用率超时

2014-11-24 18:04:06 · 作者: · 浏览: 0

问题描述:在数据库中执行查看表空间利用率语句如下:


select d.tp_name 表空间名,e.contents 类型,e.status 状态, e.extent_management 区管理,


b.bytes 大小m, b.bytes-d.bytes 已使用m,(b.bytes-d.bytes)*100/b.bytes 占用率


from (select c.tablespace_name tp_name,sum(c.bytes)/1024/1024 bytes


from dba_free_space c


group by c.tablespace_name) d,


(select a.tablespace_name tp_name,sum(a.bytes)/1024/1024 bytes


from dba_data_files a


group by a.tablespace_name) b,


(select tablespace_name tp_name,contents,status,extent_management


from dba_tablespaces )e


where d.tp_name=b.tp_name and d.tp_name=e.tp_name


order by 7;


执行1个半小时以后以超时而告终。于是我想看看该语句所用到的视图情况,执行select count(*) from dba_free_space,发现执行该语句也是很长一段时间没有反应。


原因:咨询oracle工程师得出结论:由于视图DBA_RECYCLE中数据量很大,导致dba_free_space中数据量过亿,需要清理DBA_RECYCLE中的垃圾数据:切换到sys用户下面,执行purge DBA_RECYCLE;执行了一天2夜,执行完毕以后,再次查询数据库表空间,很快变得出结论