x$bh视图
首先,这篇文章是基于如下ORACLE版本。
BANNER
------------------------------------------------
Oracle Database 10g Enterprise Edition Release 1
0.2.0.5.0 - 64bi PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Solaris: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
下面是x$bh这个视图(也许是表 :) ) 的结构。
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
DBABLK 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 data buffer的一个窗口。里面的每一条记录代表了data buffer中的一个记录。
下面的查询可以查到data buffer中有哪些数据对象的data block以及他们占用多少buffer。这里限定了表空间号大于2是为了除去一些系统表占用的buffer。
SQL> select
2 o.owner owner, o.object_name, blsiz , count(*) blocks
3 from x$bh b , dba_objects o
4 where b.obj = o.data_object_id
5 and b.ts# > 2
6 group by o.owner,o.object_name, blsiz
7 order by blocks desc; OWNER OBJECT_NAME BLSIZ BLOCKS
------------------ ------------------------------------------------ ---------- ----------
SATTEST AUDIT_LOG 8192 404
CITOSADMIN RMS_AUDIT_LOG 8192 68
CICOSADMIN BERTH_ALLOCATION 8192 14
CITOSADMIN EAS_DOCUMENT_DETAIL 8192 10
CITOSADMIN TEST 8192 8
CITOSADMIN TERMINAL2 8192 5
CITOSADMIN EAS_CONFIG 8192 5
CICOSADMIN BERTH_ALLOCATION_NNDX4 8192 4
CITOSADMIN SITE 8192 3
CICOSADMIN BERTH_ALLOCATION_NNDX3 8192 3
CITOSADMIN TERMINAL 8192 3
CICOSADMIN BERTH_ALLOCATION_NNDX2 8192 3
CICOSADMIN BERTH_ALLOCATION_NNDX1 8192 3
CITOSADMIN REEFER_PAYMENT_SCHEME 8192 1
CITOSADMIN CNTR 8192 1
SUMSADMIN SM_DISCHARGING_LIST 8192 1
CITOSADMIN CNTR_2 8192 1
CITOSADMIN GATE_PM_TRIP 8192 1
下面的查询可以查到data buffer中的某个数据对象(这里叫TEST)其占用的buffer的状态。这里看到TEST有两个cr块和6个xcur块。关于各个block的状态,cr是用于consistent read的。xcur表示是最新的块,scur也是最新的块,但scur存在于RAC中表示多个instance共享这个block。free很好理解,是可以被重用的块。
SQL> select
o.object_name
2 3 ,decode(state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec'
4 ,6,'irec',7,'write',8,'pi') state
5 , blsiz , count(*) blocks
6 from x$bh b , dba_objects o
7 where b.obj = o.data_object_id
8 and b.ts# > 0
9 and o.object_name = 'TEST'
10 group by o.object_name, state, blsiz; OBJECT_NAME STATE BLSIZ BLOCKS
------------------------------------------------ --------------- ---------- ----------
TEST cr 8192 2
TEST xcur 8192 6
下面的查询查到data buffer中特定数据对象不同状态buffer的地址信息,DBARFIL是相对文件号,是每个表空间中确定datafile的文件号,DBABLK是确定文件号后确定datablock的block number。BA是该buffer的实际addr
SQL> select
2 o.object_name
3 ,decode(state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec',6,'irec',7,'write',8,'pi') state
4 , dbarfil
5 , dbablk
6 , ba
7 from x$bh b , dba_objects o
8 where b.obj = o.data_object_id
9 and b.ts# > 0
10 and o.object_name = 'TEST'
11 ; OBJECT_NAME STATE DBARFIL DBABLK BA
------------------------------------------------ --------------- ---------- ---------- ----------------
TEST xcur 4 61470 000000038A380000
TEST xcur 4 61467 00000003866EA000
TEST xcur 4 61472 0000000385E5E000
TEST cr 4 61469 000000038BF08000
TEST cr 4 61469 0000000386F20000
TEST xcur 4 61469 000000038186C000
TEST xcur 4 61471 0000000399D5E000
TEST xcur 4 61468 0000000381716000
下面做一些操作以便熟悉该视图。
首先创建一个表如下:
create table test (id1 number,id2 number,text varchar2(2000));
insert into citosadmin.test values(1,1,'a');
insert into citosadmin.test values(2,2,'b');
insert into citosadmin.test values(3,3,'c');
alter system flush buffer_cache;
然后看一下data buffer中这个表占用的情况。占用了6个buffer
SQL> select o.owner owner, o.object_name, blsiz , count(*) blocks from x$bh b , dba_objects o
2 where b.obj = o.data_object_id and o.object_name='TEST' group by o.owner,o.object_name, blsiz; OWNER OBJECT_NAME BLSIZ BLOCKS
------------------ ------------------------------------------------ ---------- ----------
CITOSADMIN TEST 8192 6
全都是xcur状态的。xcur是表示是current的最新的block。如果是rac block和其它的instance共享则是scur。
SQL> select
2 o.object_name
3 ,decode(state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec'
4 ,6,'irec',7,'write',8,'pi') state
5 , blsiz , count(*) blocks
6 from x$bh b , dba_objects o
7 where b.obj = o.data_object_id
8 and b.ts# > 0
9 and o.object_name = 'TEST'
10 group by o.object_name, state, blsiz; OBJECT_NAME STATE BLSIZ BLOCKS
------------------------------------------------ --------------- ---------- ----------
TEST xcur 8192 6
每个buffer的地址如下
SQL> select o.object_name
2 ,decode(state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec',6,'irec',7,'write',8,'pi') state
3 , dbarfil
4 , dbablk
5 , ba
6 from x$bh b , dba_objects o
7 where b.obj = o.data_object_id
8 and o.object_name = 'TEST'; OBJECT_NAME STATE DBARFIL DBABLK BA
------------------------------------------------ --------------- ---------- ---------- ----------------
TEST xcur 4 61478 00000003816BC000
TEST xcur 4 61475 0000000389494000
TEST xcur 4 61480 000000039CEB8000
TEST xcur 4 61477 000000039CD8A000
TEST xcur 4 61479 000000038DDD8000
TEST xcur 4 61476 000000038AB52000
为了使用GV$BH视图,对上述SQL做了些更改,下面列出了使用gv$bh视图的sql语句,两两一组,上面是用x$bh下面是用gv$bh
select INST_ID, o.owner owner, o.object_name, blsiz , count(*) blocks from x$bh b , dba_objects o where b.obj = o.data_object_id and o.object_name='T' group by INST_ID, o.owner,o.object_name, blsiz; col OBJECT_NAME for a20
col OWNER for a8
select INST_ID, o.owner owner, o.object_name, count(*) blocks from gv$bh b , dba_objects o where b.objd = o.data_object_id and o.object_name='T' group by INST_ID, o.owner,o.object_name ; ------------------------------------------------------------------
select
INST_ID,
o.object_name,
decode(state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec',6,'irec',7,'write',8,'pi') state,
blsiz ,
count(*) blocks
from x$bh b , dba_objects o
where b.obj = o.data_object_id and o.object_name = 'T' group by INST_ID,o.object_name, state, blsiz; select
INST_ID,
o.object_name,
b.STATUS,
count(*) blocks
from gv$bh b , dba_objects o
where b.objd = o.data_object_id and o.object_name = 'T' group by INST_ID,o.object_name, b.STATUS ;
------------------------------------------------------------------
select
INST_ID,
o.object_name,
decode(state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec',6,'irec',7,'write',8,'pi') state,
dbarfil,
dbablk,
ba
from x$bh b , dba_objects o
where b.obj = o.data_object_id and o.object_name = 'T'; select
INST_ID,
o.object_name,
b.status,
FILE# ,
BLOCK#
from gv$bh b , dba_objects o
where b.objd = o.data_object_id and o.object_name = 'T';
------------------------------------------------------------------
x$bh视图的更多相关文章
- oracle视图V$BH && X$BH的使用列子
1创建一个测试表,test,并且插入10000行数据: SQL> create table test (id int); SQL> begin 2 for i in 1 ...
- oracle rac理解和用途扩展
Oracle RAC的优势在于利用多个节点(数据库实例)组成一个数据库,这样在保证了数据库高可用性的情况下更充分的利用了多个主机的性能,而且可以通过增加节点进行性能的扩展.实现Oracle RAC需要 ...
- Oracle buffer cache与相关的latch等待事件
buffer cache与相关的latch等待事件 1.buffer cache 2.latch:cache buffers lru chain 3.latch:cache buffers chain ...
- orace owi介绍
第1章 OWI介绍记录和观察进程所经历的等待现象的功能和界面以及方法论,统称为OWI,也就是Oracle Wait Interface.等待事件的P1.P2.P3值可以通过v$session_wait ...
- 热点块引发的cache buffers cahins latch
热点块引发的Cache buffer Chains latch: SQL语句即便适当进行了调优,有时也无法解决cache buffers cahins latch,若在编写SQL语句时的SQL工作方式 ...
- Latch free等待事件
Latch free等待事件的三个参数:p1-latch的地址:p2-latch编号:p3-请求次数.从oracle10g起,latchfree不再包含所有的latch等待,有些latch等待可能表现 ...
- Oracle 体系结构二 内存结构
Oracle实例由共享内存块(SGA)以及大量的后台进程构成. SGA必须包含的数据结构: 数据库缓冲区缓存 日志缓冲区 共享池 可选的数据结构: 大池 JAVA池 流池 其他缓冲区缓存池 用户会话还 ...
- global cache cr request
当一个进程访问需要一个或者多个块时,它会首先检查自己的CACHE是否存在该块,如果发现没有,就会先通过global cache赋予这些块 共享访问的权限,然后再访问.假如,通过global cache ...
- db file sequential read等待事件 --转载
db file sequential read db file sequential read等待事件有3个参数:file#,first block#,和block数量.在10g中,这等待事件受到用户 ...
随机推荐
- [Apple开发者帐户帮助]六、配置应用服务(5.3)推送通知(APN):从您的Web服务器发送推送通知
要使用APN从Web服务器向macOS用户发送推送通知,请注册网站推送标识符并创建网站推送证书. 对于每个网站,请注册一个网站推送标识符,用于验证通知是否来自您的服务器.然后创建一个网站推送证书以签署 ...
- [Swift通天遁地]五、高级扩展-(14)扩展String快速计算字符串中的各种数学表达式
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- [python] ThreadPoolExecutor线程池
初识 Python中已经有了threading模块,为什么还需要线程池呢,线程池又是什么东西呢?在介绍线程同步的信号量机制的时候,举得例子是爬虫的例子,需要控制同时爬取的线程数,例子中创建了20个线程 ...
- ACM_Ruin of Titanic(简单贪心)
Ruin of Titanic Time Limit: 2000/1000ms (Java/Others) Problem Description: 看完Titanic后,小G做了一个梦.梦见当泰坦尼 ...
- 本地mongochef连接其他计算机上的数据库认证失败解决方法
关闭防火墙或者在信任程序列表添加运行目录下的mongod.exe即可
- C#模拟百度登录并到指定网站评论回帖(一)
核心信息: 请求网址: https://passport.baidu.com/v2/api/?login请求方法: POST状态码: HTTP/1.1 200 OK请求头 //用户代理 Use ...
- Java系列学习(三)-基础语法
1.关键字 特点:全部小写 2.标识符 (1)就是给类,接口,方法等起名字的字符序列 (2)组成规则: A:英文大小写字母 B:数字 C:$和_ (3)注意事项: A:不能以数字开头 B:不能是jav ...
- Android Studio查看CPU使用率。
进入AS自带的CMD,依次输入: (1)进入Android Atudio安卓的目录: 1.H: 2.cd AndroidStudio\sdk\platform-tools (2)adb shell ( ...
- hdu2639,第K优决策
在dp问题中如果遇到问题,没有什么是加一维度不能解决的,如果不能,再加一维度. #include<iostream> #include<cstring> #include< ...
- Ruby开发环境的搭建
1.Ruby的下载 https://rubyinstaller.org/downloads/ 2.Ruby的安装 3.Eclipse配置Ruby开发环境 插件地址:http://rubyeclipse ...