Oracle内部视图:X$BH
2015-11-24 09:08
651 查看
以下脚本用于列出Oracle Buffer Cache的详细信息:
Filed Under: Oracle, Oracle脚本script Tagged With: buffer
cache, Oracle脚本script, x$bh
Liu 5条评论
REM List Buffer Cache Details SET LINESIZE 200 PAGESIZE 1400 SELECT /*+ ORDERED USE_HASH(o u) MERGE */ DECODE(obj#, NULL, to_char(bh.obj), u.name || '.' || o.name) name, COUNT(*) total, SUM(DECODE((DECODE(lru_flag, 8, 1, 0) + DECODE(SIGN(tch - 2), 1, 1, 0)), 2, 1, 1, 1, 0)) hot, SUM(DECODE(DECODE(SIGN(lru_flag - 8), 1, 0, 0, 0, 1) + DECODE(tch, 2, 1, 1, 1, 0, 1, 0), 2, 1, 1, 0, 0)) cold, SUM(DECODE(BITAND(flag, POWER(2, 19)), 0, 0, 1)) fts, SUM(tch) total_tch, ROUND(AVG(tch), 2) avg_tch, MAX(tch) max_tch, MIN(tch) min_tch FROM x$bh bh, sys.obj$ o, sys.user$ u WHERE bh.obj <> 4294967295 AND bh.state in (1, 2, 3) AND bh.obj = o.dataobj#(+) AND bh.inst_id = USERENV('INSTANCE') AND o.owner# = u.user#(+) -- AND o.owner# > 5 AND u.name NOT like 'AURORA$%' GROUP BY DECODE(obj#, NULL, to_char(bh.obj), u.name || '.' || o.name) ORDER BY total desc / COLUMN object_name FORMAT A30 SELECT t.name AS tablespace_name, o.object_name, SUM(DECODE(bh.status, 'free', 1, 0)) AS free, SUM(DECODE(bh.status, 'xcur', 1, 0)) AS xcur, SUM(DECODE(bh.status, 'scur', 1, 0)) AS scur, SUM(DECODE(bh.status, 'cr', 1, 0)) AS cr, SUM(DECODE(bh.status, 'read', 1, 0)) AS read, SUM(DECODE(bh.status, 'mrec', 1, 0)) AS mrec, SUM(DECODE(bh.status, 'irec', 1, 0)) AS irec FROM v$bh bh JOIN dba_objects o ON o.data_object_id = bh.objd JOIN v$tablespace t ON t.ts# = bh.ts# GROUP BY t.name, o.object_name order by xcur desc / set pages 999 set lines 92 ttitle 'Contents of Data Buffers' drop view buffer_map; create view buffer_map as select o.owner owner, o.object_name object_name, o.subobject_name subobject_name, o.object_type object_type, count(distinct file# || block#) num_blocks from dba_objects o, v$bh bh where o.data_object_id = bh.objd -- and o.owner not in ('SYS','SYSTEM') and bh.status != 'free' group by o.owner, o.object_name, o.subobject_name, o.object_type order by count(distinct file# || block#) desc ; column c0 heading "Owner" format a12 column c1 heading "Object|Name" format a30 column c2 heading "Object|Type" format a8 column c3 heading "Number of|Blocks in|Buffer|Cache" format 99,999,999 column c4 heading "Percentage|of object|blocks in|Buffer" format 999 column c5 heading "Buffer|Pool" format a7 column c6 heading "Block|Size" format 99,999 select buffer_map.owner c0, object_name c1, case when object_type = 'TABLE PARTITION' then 'TAB PART' when object_type = 'INDEX PARTITION' then 'IDX PART' else object_type end c2, sum(num_blocks) c3, (sum(num_blocks)/greatest(sum(blocks), .001))*100 c4, buffer_pool c5, sum(bytes)/sum(blocks) c6 from buffer_map, dba_segments s where s.segment_name = buffer_map.object_name and s.owner = buffer_map.owner and s.segment_type = buffer_map.object_type and nvl(s.partition_name,'-') = nvl(buffer_map.subobject_name,'-') group by buffer_map.owner, object_name, object_type, buffer_pool having sum(num_blocks) > 10 order by sum(num_blocks) desc ; REM dbbuffer select decode(pd.bp_id,1,'KEEP',2,'RECYCLE',3,'DEFAULT', 4,'2K SUBCACHE',5,'4K SUBCACHE',6,'8K SUBCACHE', 7,'16K SUBCACHE',8,'32KSUBCACHE','UNKNOWN') subcache, bh.object_name,bh.blocks from x$kcbwds ds,x$kcbwbpd pd,(select /*+ use_hash(x) */ set_ds, o.name object_name,count(*) BLOCKS from obj$ o, x$bh x where o.dataobj# = x.obj and x.state !=0 and o.owner# !=0 group by set_ds,o.name) bh where ds.set_id >= pd.bp_lo_sid and ds.set_id <= pd.bp_hi_sid and pd.bp_size != 0 and ds.addr=bh.set_ds; column segment_name format a35 select /*+ RULE */ e.owner ||'.'|| e.segment_name segment_name, e.extent_id extent#, x.dlk - e.block_id + 1 block#, x.tch, l.child# from sys.v$latch_children l, sys.x$bh x, sys.dba_extents e where x.hladdr = '&ADDR' and e.file_id = x.file# and x.hladdr = l.addr and x.dk between e.block_id and e.block_id + e.blocks -1 order by x.tch desc / with bh_lc as (select /*+ ORDERED */ lc.addr, lc.child#, lc.gets, lc.misses, lc.immediate_gets, lc.immediate_misses, lc.spin_gets, lc.sleeps, bh.hladdr, bh.tch tch, bh.file#, bh.dk, bh.class, bh.state, bh.obj from x$kslld ld, v$session_wait sw, v$latch_children lc, x$bh bh where lc.addr =sw.p1raw and sw.p2= ld.indx and ld.kslldnam='cache buffers chains' and lower(sw.event) like '%latch%' and sw.state='WAITING' and bh.hladdr=lc.addr ) select bh_lc.hladdr, bh_lc.tch, o.owner, o.object_name, o.object_type, bh_lc.child#, bh_lc.gets, bh_lc.misses, bh_lc.immediate_gets, bh_lc.immediate_misses, spin_gets, sleeps from bh_lc, dba_objects o where bh_lc.obj = o.object_id(+) union select bh_lc.hladdr, bh_lc.tch, o.owner, o.object_name, o.object_type, bh_lc.child#, bh_lc.gets, bh_lc.misses, bh_lc.immediate_gets, bh_lc.immediate_misses, spin_gets, sleeps from bh_lc, dba_objects o where bh_lc.obj = o.data_object_id(+) order by 1,2 desc / col class form A10 select decode(greatest(class,10),10,decode(class,1,'Data',2 ,'Sort',4,'Header',to_char(class)),'Rollback') "Class", sum(decode(bitand(flag,1),1,0,1)) "Not Dirty", sum(decode(bitand(flag,1),1,1,0)) "Dirty", sum(dirty_queue) "On Dirty",count(*) "Total" from x$bh group by decode(greatest(class,10),10,decode(class,1,'Data',2 ,'Sort',4,'Header',to_char(class)),'Rollback') /
Filed Under: Oracle, Oracle脚本script Tagged With: buffer
cache, Oracle脚本script, x$bh
Oracle内部视图:X$BH
2007/06/22 by MacleanLiu 5条评论
X$BH Fixed Table Buffer Cache Diagram Column Type Description ~~~~~~ ~~~~~ ~~~~~~~~~~~ ADDR RAW(4) Hex address of the Buffer Header. INDX NUMBER Buffer Header number BUF# NUMBER HLADDR RAW(4) Hash Chain Latch Address See . ADDR LRU_FLAG NUMBER 8.1+ LRU flag KCBBHLDF 0x01 8.1 LRU Dump Flag used in debug print routine KCBBHLMT 0x02 8.1 moved to tail of lru (for extended stats) KCBBHLAL 0x04 8.1 on auxiliary list KCBBHLHB 0x08 8.1 hot buffer - not in cold portion of lru FLAG NUMBER KCBBHFBD 0x00001 buffer dirty KCBBHFAM 0x00002 7.3 about to modify; try not to start io KCBBHFAM 0x00002 8.0 about to modify; try not to start io KCBBHNAC 0x00002 8.1 notify dbwr after change KCBBHFMS 0x00004 modification started, no new writes KCBBHFBL 0x00008 block logged KCBBHFTD 0x00010 temporary data - no redo for changes KCBBHFBW 0x00020 being written; can't modify KCBBHFWW 0x00040 waiting for write to finish KCBBHFCK 0x00080 7.3 checkpoint asap 0x00080 8.0 not used KCBBHFMW 0x00080 8.1 multiple waiters when gc lock acquired KCBBHFRR 0x00100 recovery reading, do not reuse, being read KCBBHFUL 0x00200 unlink from lock element - make non-current KCBBHFDG 0x00400 write block & stop using for lock down grade KCBBHFCW 0x00800 write block for cross instance call KCBBHFCR 0x01000 reading from disk into KCBBHCR buffer KCBBHFGC 0x02000 has been gotten in current mode KCBBHFST 0x04000 stale - unused CR buf made from current 0x08000 7.3 Not used. KCBBHFDP 0x08000 8.0 deferred ping KCBBHFDP 0x08000 8.1 deferred ping KCBBHFDA 0x10000 Direct Access to buffer contents KCBBHFHD 0x20000 Hash chain Dump used in debug print routine KCBBHFIR 0x40000 Ignore Redo for instance recovery KCBBHFSQ 0x80000 sequential scan only flag KCBBHFNW 0x100000 7.3 Set to indicate a buffer that is NEW 0x100000 8.0 Not used KCBBHFBP 0x100000 8.1 Indicates that buffer was prefetched KCBBHFRW 0x200000 7.3 re-write if being written (sort) 0x200000 8.0 Not used KCBBHFFW 0x200000 8.1 Buffer has been written once KCBBHFFB 0x400000 buffer is "logically" flushed KCBBHFRS 0x800000 ReSilvered already - do not redirty KCBBHFKW 0x1000000 7.3 ckpt writing flag to avoid rescan */ 0x1000000 8.0 Not used KCBBHDRC 0x1000000 8.1 buffer is nocache 0x2000000 7.3 Not used KCBBHFRG 0x2000000 8.0 Redo Generated since block read KCBBHFRG 0x2000000 8.1 Redo Generated since block read KCBBHFWS 0x10000000 8.0 Skipped write for checkpoint. KCBBHFDB 0x20000000 8.1 buffer is directly from a foreign DB KCBBHFAW 0x40000000 8.0 Flush after writing KCBBHFAW 0x40000000 8.1 Flush after writing TS# NUMBER 8.X Tablespace number DBARFIL NUMBER 8.X Relative file number of block DBAFIL NUMBER 7.3 File number of block DB NUMBER Block number of block CLASS NUMBER See Note 33434.1 1,'data block', 2,'sort block', 3,'save undo block', 4,'segment header', 5,'save undo header', 6,'free list', 7,'extent map', 8,'1st level bmb', 9,'2nd level bmb', 10,'3rd level bmb', 11,'bitmap block', 12,'bitmap index block', 13,'file header block', 14,'unused', 15,'system undo header', 16,'system undo block', 17,'undo header', 18,'undo block' -- since 10g STATE NUMBER KCBBHFREE 0 buffer free KCBBHEXLCUR 1 buffer current (and if DFS locked X) KCBBHSHRCUR 2 buffer current (and if DFS locked S) KCBBHCR 3 buffer consistant read KCBBHREADING 4 Being read KCBBHMRECOVERY 5 media recovery (current & special) KCBBHIRECOVERY 6 Instance recovery (somewhat special) MODE_HELD NUMBER Mode buffer held in (MODE pre 7.3) 0=KCBMNULL, KCBMSHARE, KCBMEXCL CHANGES NUMBER CSTATE NUMBER X_TO_NULL NUMBER Count of PINGS out (OPS) DIRTY_QUEUE NUMBER You wont normally see buffers on the LRUW LE_ADDR RAW(4) Lock Element address (OPS) SET_DS RAW(4) Buffer cache set this buffer is under OBJ NUMBER Data object number TCH NUMBER 8.1 Touch Count TIM NUMBER 8.1 Touch Time BA RAW(4) CR_SCN_BAS NUMBER Consistent Read SCN base CR_SCN_WRP NUMBER Consistent Read SCN wrap CR_XID_USN NUMBER CR XID Undo segment no CR_XID_SLT NUMBER CR XID slot CR_XID_SQN NUMBER CR XID Sequence CR_UBA_FIL NUMBER CR UBA file CR_UBA_BLK NUMBER CR UBA Block CR_UBA_SEQ NUMBER CR UBA sequence CR_UBA_REC NUMBER CR UBA record CR_SFL NUMBER LRBA_SEQ NUMBER } Lowest RBA needed to recover block in cache LRBA_BNO NUMBER } LRBA_BOF NUMBER } HRBA_SEQ NUMBER } Redo RBA to be flushed BEFORE this block HRBA_BNO NUMBER } can be written out HRBA_BOF NUMBER } RRBA_SEQ NUMBER } Block recovery RBA RRBA_BNO NUMBER } RRBA_BOF NUMBER } NXT_HASH NUMBER Next buffer on this hash chain PRV_HASH NUMBER Previous buffer on this hash chain NXT_LRU NUMBER Next buffer on the LRU PRV_LRU NUMBER Previous buffer on the LRU US_NXT RAW(4) US_PRV RAW(4) WA_NXT RAW(4) WA_PRV RAW(4) ACC RAW(4) MOD RAW(4)
相关文章推荐
- Oracle用户解锁
- 免安装Oracle客户端软件-使用pl/sql配置登陆
- Oracle DECODE函数的用法详解
- Oracle 查询库中所有表名、字段名、表名说明、字段名说明(原创)
- Oracle学习——第一章
- oracle 学习笔记
- 如何在oracle数据库里面建立多个用户连接到plsql客户端
- Hibernate学习总结之配置注意事项
- Oracle中创建表时Storage字段的含义
- 解决oracle乱码问题
- Oracle 乱码或则中文无法正确查询问题
- JDBC 链接oracle数据库(toad oci连接在64位解决办法)
- Oracle卸载
- 解决oracle重启后出现无法连接问题
- hibernate学习总结之子类关系映射
- Oracle数据库启动问题
- win7 64位操作系统安装oracle客户端和plsql问题解决办法
- WEB服务器安装oracle jdbc
- WEB服务器安装oracle jdbc
- Oracle数据库按时间进行分组统计数据的方法