关于dirtybuffer

来源:互联网 发布:电气专业软件plc 编辑:程序博客网 时间:2024/06/01 11:19
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

其实大家对v$bh这个视图可能一直重视不够.

我们来看一下这个视图主要字段说明:


STATUS

VARCHAR2(1)

Statusofthebuffer:
FREE-notcurrentlyinuseXCUR-exclusiveSCUR-sharedcurrentCR-consistentreadREAD-beingreadfromdiskMREC-inmediarecoverymodeIREC-ininstancerecoverymode?


DIRTY

VARCHAR2(1)

Y-blockmodified

TEMP

VARCHAR2(1)

Y-temporaryblock

PING

VARCHAR2(1)

Y-blockpinged

STALE

VARCHAR2(1)

Y-blockisstale

DIRECT

VARCHAR2(1)

Y-directblock


?

我们注意到v$dirty代表的就是blockmodified

?

如果我们进一步向下追溯:

SQL>selectVIEW_DEFINITIONfromv$fixed_view_definitionwhereVIEW_NAME='GV$BH';

VIEW_DEFINITION
--------------------------------------------------------------------------------
selectbh.inst_id,file#,dbablk,class,decode(state,0,'free',1,'xcur',2,'scur'
,3,'cr',4,'read',5,'mrec',6,'irec',7,'write',8,'pi'),x_to_null,forced_reads,
forced_writes,bh.le_addr,name,le_class,decode(bitand(flag,1),0,'N','Y'),d
ecode(bitand(flag,16),0,'N','Y'),decode(bitand(flag,1536),0,'N','Y'),dec
ode(bitand(flag,16384),0,'N','Y'),decode(bitand(flag,65536),0,'N','Y'),'
N',obj,ts#fromx$bhbh,x$lelewherebh.le_addr=le.le_addr(+)


我们可以看到v$bh的底层表示x$bh

其中v$bh中的dirty/temp/ping/stale/direct五个字段来源于x$bh中的flag字段

格式化一下输出:

SELECTbh.inst_id,file#,dbablk,CLASS,
??????DECODE(state,
??????????????0,'free',
??????????????1,'xcur',
??????????????2,'scur',
??????????????3,'cr',
??????????????4,'read',
??????????????5,'mrec',
??????????????6,'irec',
??????????????7,'write',
??????????????8,'pi'
?????????????),
??????x_to_null,forced_reads,forced_writes,bh.le_addr,NAME,le_class,
??????DECODE(BITAND(flag,1),0,'N','Y'),
??????DECODE(BITAND(flag,16),0,'N','Y'),
??????DECODE(BITAND(flag,1536),0,'N','Y'),
??????DECODE(BITAND(flag,16384),0,'N','Y'),
??????DECODE(BITAND(flag,65536),0,'N','Y'),'N',obj,ts#
?FROMx$bhbh,x$lele
?WHEREbh.le_addr=le.le_addr(+)


由此我们得以窥视x$bh.flag的深层含义.
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>