The Oracle (tm) Users' Co-Operative FAQ
Queries against dba_free_space with locally managed tablespaces are slow - is there any way to speed them up ?
| 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. |
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.
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.
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#;
Further reading: n/a
最后修改时间:2020-04-16 15:11:50
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




