10g 回收站(RECYCLE BIN)导致查询表空间的利用率时很慢

来源:互联网 发布:苹果电脑翻墙 软件 编辑:程序博客网 时间:2024/06/03 17:22

一日使用OEM检查数据库(10g)数据文件、表空间时,发现页面弹出很慢,大概需要十几分钟!

以前在9i中使用OEM检查数据文件、表空间时,页面弹出很快。后来发现是由于10g recyclebin的原因。

1、使用sys用户登录

2SQL>select count(*) from sys.recyclebin$;

9657

SQL>select count(*) from recyclebin;

0

3SQL>purge recyclebin; --purge当前用户在回收站中的对象

Done.

4SQL>select count(*) from recyclebin;

0

SQL>select count(*) from sys.recyclebin$;

9657

5SQL>purge dba_recyclebin; --purge所有用户在回收站中的对象

Done

6SQL>select count(*) from recyclebin;

0

SQL>select count(*) from sys.recyclebin$;

0

7、再次使用OEM查询数据文件、表空间,页面弹出很快。


8
、关闭回收站

SQL>alter system set recyclebin=off scope=both sid='*';

purge掉回收站的内容后再次查询表空间页面,弹出很快。

eygle的一篇文章中提到:

关于dba_free_space视图的构成,9i 10g发生了变化。在Oracle10g中,如果启用flash drop功能,在drop表时,数据库不会直接删除,而是将其放在回收站中,当空间出现短缺时,才会逐渐回收这部分空间。当对象删除之后,这部分空间会记入free space,也就是说被包含在dba_free_space的查询结果之中。

我们看一下这个视图的变化,在Oracle9i之中,这个视图构建如下:

SQL> set long 9999
SQL> set pagesize 99
SQL> select text from dba_views where view_name=upper('&view_name');
Enter value for view_name: dba_free_space
old 1: select text from dba_views where view_name=upper('&view_name')
new 1: select text from dba_views where view_name=upper('dba_free_space')

TEXT
--------------------------------------------------------------------------------
select ts.name, fi.file#, f.block#,
f.length * ts.blocksize, f.length, f.file#
from sys.ts$ ts, sys.fet$ f, sys.file$ fi
where ts.ts# = f.ts#
and f.ts# = fi.ts#
and f.file# = fi.relfile#
and ts.bitmapped = 0
union all
select /*+ ordered use_nl(f) use_nl(fi) */
ts.name, fi.file#, f.ktfbfebno,
f.ktfbfeblks * ts.blocksize, f.ktfbfeblks, f.ktfbfefno
from sys.ts$ ts, sys.x$ktfbfe f, sys.file$ fi
where ts.ts# = f.ktfbfetsn
and f.ktfbfetsn = fi.ts#
and f.ktfbfefno = fi.relfile#
and ts.bitmapped <> 0 and ts.online$ in (1,4) and ts.contents$ = 0

而在Oracle10g中,这个视图增加了关于recyclebin的部分:

SQL> set long 9999
SQL> set pagesize 99
SQL> select text from dba_views where view_name=upper('&view_name');
Enter value for view_name: dba_free_space
old 1: select text from dba_views where view_name=upper('&view_name')
new 1: select text from dba_views where view_name=upper('dba_free_space')

TEXT
--------------------------------------------------------------------------------
select ts.name, fi.file#, f.block#,
f.length * ts.blocksize, f.length, f.file#
from sys.ts$ ts, sys.fet$ f, sys.file$ fi
where ts.ts# = f.ts#
and f.ts# = fi.ts#
and f.file# = fi.relfile#
and ts.bitmapped = 0
union all
select /*+ ordered use_nl(f) use_nl(fi) */
ts.name, fi.file#, f.ktfbfebno,
f.ktfbfeblks * ts.blocksize, f.ktfbfeblks, f.ktfbfefno
from sys.ts$ ts, sys.x$ktfbfe f, sys.file$ fi
where ts.ts# = f.ktfbfetsn
and f.ktfbfetsn = fi.ts#
and f.ktfbfefno = fi.relfile#
and ts.bitmapped <> 0 and ts.online$ in (1,4) and ts.contents$ = 0
union all
select /*+ ordered use_nl(u) use_nl(fi) */
ts.name, fi.file#, u.ktfbuebno,
u.ktfbueblks * ts.blocksize, u.ktfbueblks, u.ktfbuefno
from sys.
recyclebin$ rb, sys.ts$ ts, sys.x$ktfbue u, sys.file$ fi
where ts.ts# = rb.ts#
and rb.ts# = fi.ts#
and rb.file# = fi.relfile#
and u.ktfbuesegtsn = rb.ts#
and u.ktfbuesegfno = rb.file#
and u.ktfbuesegbno = rb.block#
and ts.bitmapped <> 0 and ts.online$ in (1,4) and ts.contents$ = 0
union all
select ts.name, fi.file#, u.block#,
u.length * ts.blocksize, u.length, u.file#
from sys.ts$ ts, sys.uet$ u, sys.file$ fi, sys.
recyclebin$ rb
where ts.ts# = u.ts#
and u.ts# = fi.ts#
and u.segfile# = fi.relfile#
and u.ts# = rb.ts#
and u.segfile# = rb.file#
and u.segblock# = rb.block#
and ts.bitmapped = 0

这就是Oracle10g的回收站(recyclebin)和自由空间管理的变化。

Oracle10g中,有时候查询dba_free_space视图异常缓慢,就是因为recyclebin中对象太多的缘故。

 

 

原创粉丝点击