数据库

img ern

ORA FAQ 性能调整系列之——本地管理表空间环境下查询dba_free_space很慢——有什么办法加速么?

发表于2004/9/30 10:08:00  1820人阅读

分类: 数据库

ORA FAQ 性能调整系列之——
Queries against dba_free_space with locally managed tablespaces are slow - is there any way to speed them up ?
本地管理表空间环境下查询dba_free_space很慢——有什么办法加速么?
--------------------------------------------------------------------------------

Author's name: Hans-Peter Sloot
Author's Email:Hans-Peter.Sloot@atosorigin.com
Date written: 9th August 2003
Oracle version(s): 8i
 
When Oracle introduced Locally managed tablespaces, they had to change their definition of the view dba_free_space to report free space in locally managed tablespaces. As a result, some systems have very poor response times when reporting free space. Is there anything you can do.
当Oracle引入本地管理表空间,他们不得不修改了视图dba_free_space的定义来报告本地管理表空间的空闲空间。于是一些系统在报告空闲空间时响应时间很差。我们能做什么?

--------------------------------------------------------------------------------

Just because Oracle Corp. supplies a view definition, that doesn't mean you have to use it. You might create a new definition of dba_free_space that is much faster than the original one.
Oracle公司提供了一个视图定义,并不意味着你必须使用它。你可以创建一个比原先快的新dba_free_space定义。

On one database used for BAAN a query on dba_free_space lasted 50 minutes, whereas the following new definition returned the same results within 50 seconds.Of course, as versions of Oracle change, you may have to keep updating the definitions of your views to cater for new features.
用于BAAN的一个数据库上,一个对dba_free_space的查询持续了50分钟,而下面的新定义在50秒内返回了同样的结果。随着Oracle版本变迁,你可能得保持更新你的视图的定义来利用新特性。

CREATE OR REPLACE VIEW DBA_FREE_SPACE_NEW (
 TABLESPACE_NAME,
 FILE_ID,
 BLOCK_ID,
 BYTES,
 BLOCKS,
 RELATIVE_FNO
) AS
select /*+use_hash (tsfi, fet2 ) */
 tsfi.tablespace_name, tsfi.file_id, fet2.block_id,
 tsfi.blocksize * fet2.blocks, fet2.blocks, tsfi.relfile#
from
 (
   select /*+ use_hash ( ts, fi ) */
      ts.name tablespace_name, fi.file# file_id, ts.BLOCKSIZE,
      fi.relfile#, ts.ts#
   from sys.ts$ ts, sys.file$ fi
   where ts.ts# = fi.ts#
   and ts.online$ in (1,4)
 ) tsfi,
 (
   select f.block# block_id, f.length blocks, f.file# file_id, f.ts#
   from sys.fet$ f
   union all
   select f.ktfbfebno block_id, f.ktfbfeblks blocks, f.ktfbfefno, ktfbfetsn
   from sys.x_$ktfbfe f
 ) fet2        
where
   fet2.file_id = tsfi.relfile# and
   fet2.ts# = tsfi.ts#;
--------------------------------------------------------------------------------
本文翻译自http://www.jlcomp.demon.co.uk/faq/autotrace_pruning.html  译者仅保留翻译版权

阅读全文
0 0

相关文章推荐

img
取 消
img