ImageVerifierCode 换一换
格式:PPT , 页数:85 ,大小:2.61MB ,
文档编号:3571579      下载积分:28 文币
快捷下载
登录下载
邮箱/手机:
温馨提示:
系统将以此处填写的邮箱或者手机号生成账号和密码,方便再次下载。 如填写123,账号和密码都是123。
支付方式: 支付宝    微信支付   
验证码:   换一换

优惠套餐
 

温馨提示:若手机下载失败,请复制以下地址【https://www.163wenku.com/d-3571579.html】到电脑浏览器->登陆(账号密码均为手机号或邮箱;不要扫码登陆)->重新下载(不再收费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  
下载须知

1: 试题类文档的标题没说有答案,则无答案;主观题也可能无答案。PPT的音视频可能无法播放。 请谨慎下单,一旦售出,概不退换。
2: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
3: 本文为用户(三亚风情)主动上传,所有收益归该用户。163文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

1,本文([计算机软件及应用]Buffercache课件.ppt)为本站会员(三亚风情)主动上传,163文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。
2,用户下载本文档,所消耗的文币(积分)将全额增加到上传者的账号。
3, 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(发送邮件至3464097650@qq.com或直接QQ联系客服),我们立即给予删除!

[计算机软件及应用]Buffercache课件.ppt

1、Buffer Cache Waits#.2In This Section1.latch:cache buffers chains 2.latch:cache buffers lru chain 3.latch:cache buffer handles4.Free Buffer Wait5.Buffer Busy Wait6.Write Complete Wait7.Buffer Exterminate#.3Buffer Cache#.4Oracle Memory Structures#.5Buffer Cache AccessBuffer Cache ManagementLocating Fr

2、ee blocksFinding data blocksManaging LRU listsCleaning Dirty BlocksBuffer Cache management can cause contentionDifferent from IO(reading blocks of disk)#.6Query0.Parse statement1.Find object information in data dictionary2.Calculate execution plan3.If full table scanLook at all blocks of table4.If i

3、ndex find root of index and follow to key5.Data Dictionary will have info about table or index blockFile#Block#6.Once you know the block DBA(file#+block#)Select ename from emp where empno=12;#.7Is Block in cache?Now you have a file#and block#How do you know if a block is cached?Do you search all the

4、 blocks?Could be 1000s of blocks to search.Buffer caches are in the multi Gig#.8Buffer CacheFind a block by:1)Hash ofData file#Block#2)Result =Bucket#3)Search linked list for that bucket#What is a hash valueWhat are Buckets What is the linked list?#.9ConceptsTo understand contention on the buffer ca

5、che,need to understand:1.Linked Lists2.Hashing3.Buckets#.10Double Linked Lists 03C3900003C3947803C38F6003C3900003C3900003C38F6003C39478AddressNextPrevious#.11Hashing Function Simple hash could be a Mod function1 mod 4=12 mod 4=23 mod 4=34 mod 4=05 mod 4=16 mod 4=27 mod 4=38 mod 4=0 Using“mod 4”as a

6、hash funtion creates 4“buckets”to store things#.12Hash Bucket FillData BlockData BlockHash Blocks Hash Blocks file#file#block#sblock#sResult in a bucket#Result in a bucket#Put Block in bucketPut Block in bucket?Hash Blocks Hash Blocks 1 file#1 file#437 block#s437 block#s(1+437)mod 4=2(1+437)mod 4=2#

7、.13Latches Protect Bucket ContentsBufferHeadersData BlocksHashbucketlatchesBuffer Headers contents described by X$BH#.14X$bhDescribes Contents of Buffer HeadersSQL desc x$bh Name Type-ADDR RAW(4)DBARFIL NUMBER DBABLK NUMBER OBJ NUMBER HLADDR RAW(4)NXT_HASH RAW(4)PRV_HASH RAW(4)much more ADDR DBARFIL

8、 DBABLK OBJ HLADDR NXT_HASH PRV_HASHA each buffer header contains Information about the data block It points to and the previous and next Buffer header in a linked list#.15Cache 03C3900003C3947803C38F6003C3900003C3900003C38F6003C39478ADDRNXT_HASHPRV_HASH#.16X$BH describes HeadersBufferHeadersData Bl

9、ocksHashbucketlatchesHLADDRNXT_HASHPRV_HASHADDR ADDRDBARFILDBABLKOBJx$bh ADDR DBARFIL DBABLK OBJ HLADDR NXT_HASH PRV_HASH#.17To Find a Block1.Hash the block address2.Get Bucket latch3.Look for header4.Found,read block in cache5.Not Found Read block off diskBufferHeadersData BlocksHashbucketlatches#.

10、18Cache Buffers ChainsHash BucketslatchesBlockHeadersCache Buffer ChainDataBlocks#.19ExamplesS1S2S3S41.Look up Table2.Nested LoopsSelect t1.val,t2.valfrom t1,t2where t1.c1=value and t2.id=t1.id;t1Index_t2t2#.20CBC SolutionsFind SQL(Why is application hitting the block so hard?)Nested loops,possiblyH

11、ash PartitionUses Hash Join Hash clustersLook up tables(“select language from lang_table where.”)Change applicationUse plsql functionSpread data out to reduce contentionSelect from dualPossibly use x$dualHow do you find the SQL?#.21CBC:Statspack 9iTop 5 Timed Events%TotalEvent Waits Time(s)Ela Time-

12、latch free 21,428 1,914 81.37CPU time 360 15.29PL/SQL lock timer 16 48 2.04SQL*Net message from dblink 4,690 14 .58db file sequential read 1,427 5 .19Top 5 Timed Events%TotalEvent Waits Time(s)Ela Time-latch free 21,428 1,914 81.37CPU time 360 15.29PL/SQL lock timer 16 48 2.04SQL*Net message from db

13、link 4,690 14 .58db file sequential read 1,427 5 .19Latch Sleep breakdown for DB:CDB Instance:cdb Snaps:1-2-ordered by misses descLatch Name Requests Misses Sleeps Sleeps 1-4-cache buffers chains 12,123,500 608,415 15,759 0/0/0/0/0library cache pin 12,027,599 173,446 2,862 172694/743/8/1/0library ca

14、che 12,072,503 98,065 2,373 97739/279/47/0/0simulator lru latch 606 436 434 6/426/4/0/0Fails to find SQL#.22CBC:Statspack 10gTop 5 Timed Events Avg%Total wait CallEvent Waits Time(s)(ms)Time-CPU time 35 54.3latch:cache buffers chains 46 11 243 17.6latch:library cache pin 35 8 229 12.6latch:library c

15、ache 27 6 231 9.8log file sequential read 15 1 60 1.4Top 5 Timed Events Avg%Total wait CallEvent Waits Time(s)(ms)Time-CPU time 35 54.3latch:cache buffers chains 46 11 243 17.6latch:library cache pin 35 8 229 12.6latch:library cache 27 6 231 9.8log file sequential read 15 1 60 1.4Fails to find SQL#.

16、23CBC:ASH select count(*),sql_id,nvl(o.object_name,ash.current_obj#)objn,substr(o.object_type,0,10)otype,CURRENT_FILE#fn,CURRENT_BLOCK#blocknfrom v$active_session_history ash ,all_objects owhere event like latch:cache buffers chains and o.object_id(+)=ash.CURRENT_OBJ#group by sql_id,current_obj#,cur

17、rent_file#,current_block#,o.object_name,o.object_typeorder by count(*)/CNT SQL_ID OBJN OTYPE FN BLOCKN-84 a09r4dwjpv01q MYDUAL TABLE 1 93170SQL Statement:SuccessExtra:Hot block#.24CBC:OEM#.25CBC:ADDMProblemSQL StatementSolution?#.26CBC Further Investigationselect*from v$event_namewhere name=latch:ca

18、che buffers chains EVENT#NAME -58 latch:cache buffers chains PARAMETER1 PARAMETER2 PARAMETER3-address number tries NOTE:_db_block_hash_buckets=#of hash buckets _db_blocks_per_hash_latch=#of hash latches#.27CBC:whats the hot blockCan get it from ASH Current_file#Current_block#Where event=latch:cache

19、buffers chains”Sometimes file and block=0Seems to happen for Nested LoopsGet the hot block real timeUse Hash Latch Address Ash.p2=x$bh.hladdr#.28Hot Block:X$BH.TCHUpdated when block readUpdated by no more than 1 every 3 secondsCan be used to find“hot”blocksNote:set back to zero when block cycles thr

20、ough the buffer cache#.29CBC Real Timeselect count(*),lpad(replace(to_char(p1,XXXXXXXXX),0),16,0)laddrfrom v$active_session_historywhere event=latch:cache buffers chainsgroup by p1;select o.name,bh.dbarfil,bh.dbablk,bh.tchfrom x$bh bh,obj$owhere tch 100 and hladdr=00000004D8108330 and o.obj#=bh.objo

21、rder by tch COUNT(*)LADDR-4933 00000004D8108330NAME DBARFIL DBABLK TCH-EMP_CLUSTER 4 394 120#.30Putting into one Queryselect name,file#,dbablk,obj,tch,hladdr from x$bh bh ,obj$o where o.obj#(+)=bh.obj and hladdr in(select ltrim(to_char(p1,XXXXXXXXXX)from v$active_session_history where event like lat

22、ch:cache%group by p1 having count(*)5)and tch 5order by tch NAME FILE#DBABLK OBJ TCH HLADDR-BBW_INDEX 1 110997 66051 17 6BD91180IDL_UB1$1 54837 73 18 6BDB8A80VIEW$1 6885 63 20 6BD91180VIEW$1 6886 63 24 6BDB8A80DUAL 1 2082 258 32 6BDB8A80DUAL 1 2081 258 32 6BD91180MGMT_EMD_PING 3 26479 50312 272 6BDB

23、8A80This can be misleading,as TCH gets set to 0 ever rap around the LRU and it only gets updated once every 3 seconds,so in this case DUAL was my problem table not MGMT_EMD_PING#.31Consistent Read BlocksCurrentBlock(XCUR)Update Select ConsistentRead(CR)Clone&Undo Both have same file#and block#and ha

24、sh to same bucket#.32latchesCBC:Consistent Read BlocksCache Buffer ChainHash BucketsBlockHeadersMax length:_db_block_max_cr_dba10g=6#.33Consistent Read Copiesselect count(*),name ,file#,dbablk ,hladdr from x$bh bh ,obj$owhere o.obj#(+)=bh.obj and hladdr in(select ltrim(to_char(p1,XXXXXXXXXX)from v$a

25、ctive_session_history where event like latch:cache%group by p1)group by name,file#,dbablk,hladdrhaving count(*)1order by count(*);CNT NAME FILE#DBABLK HLADDR-14 MYDUAL 1 93170 2C9F4B20#.34CBC:Solution Fine the SQL causing the problemChange Application Logic Eliminate hot spotsLook up tablesUses pl/s

26、ql functionsMinimize data per blockPossibly using x$dual instead of dualIndex Nested loops Hash joinHash partition indexHah Cluster Updates,inserts,select for update on blocks while reading those blocksCause multiple copiesselect ash.sql_id,count(*),sql_textfrom v$active_session_history ash,v$sqlsta

27、ts sqlwhere event=latch:cache buffers chainsand sql.sql_id(+)=ash.sql_idgroup by ash.sql_id,sql_text;#.35Latch:cache buffer handlesBuffers can be pinned Possibly increase_db_handles_cached 5UnsupportedUsed when pinning block headers for expected reuse#.36Free Buffer WaitData Block Cache lack free bu

28、ffersTune byIncrease data blocksTry to tune DBWRImproving Inefficient SQL requesting large#of blocks#.37Free Buffer Wait Finding a Free BlockIf the data block isnt in cache Get a free block and header in the buffer cacheRead it off diskUpdate the free headerRead the block into the buffer cacheNeed F

29、ree Block to Read in New Data Block#.38Finding a Free Block#.39Finding a Free BlockBufferHeadersData BlocksHashbucketlatches1.Arrange the Buffer Headers into an LRU List2.Scan LRU for a free block#.40Cache Buffers LRU=entry in x$bh#.41X$bhDescribes Buffer HeadersSQL desc x$bh Name Type-ADDR RAW(4)DB

30、ARFIL NUMBER DBABLK NUMBER OBJ NUMBER HLADDR RAW(4)NXT_HASH RAW(4)PRV_HASH RAW(4)NXT_REPL RAW(4)PRV_REPL RAW(4)NXT_REPL RAW(4)PRV_REPL RAW(4)HLADDR RAW(4)NXT_HASH RAW(4)PRV_HASH RAW(4)Cache buffer chainsLRU#.42LRU Chain 03C3900003C38F6003C38F6003C3900003C3900003C38F6003C39478ADDRNXT_HASHPRV_HASH03C3

31、947803C3851403C3863803C3862003C385F403C38554NXT_REPL PRV_REPL#.43Cache Buffers LRU list#.44Cache Buffers LRU listLRU Chain of Buffer HeadersBuffer Cache#.45Cache Buffers LRU LatchBuffer Headers“Cold”LRU=Least Recently UsedMRU=Most Recently Used“Hot”LRU latch#.46Session Searching for Free BlocksBuffe

32、r HeadersSession Shadow1.Go to the LRU end of data blocks2.Look for first non-dirty block3.If search too many post DBWR to make free4.Free Buffer wait#.47Free Buffer Wait SolutionsTune byIncrease data blocksTry to tune DBWRASYNCIf no ASYNC use I/O Slaves(dbwr_io_slaves)Multiple DBWR(db_writer_proces

33、ses)Direct I/OTune Inefficient SQL requesting large#of blocks#.48Session Finding a Free BlockHot EndsessionLRU Latch#.49DBWR taking Dirty Blocks offBuffer Headers LRUDBWRDirty List of Buffer Headers LRUWlatchLRU latch also covers DBWR list of dirty blocs#.50Cache Buffers LRU Latch#.51Solution:LRU La

34、tch 1LRU Latch 2#.52Working Sets select ds.set_id,ds.blk_size,bp.BUFFERS,nvl(bp.name.unused)from x$kcbwds ds,v$buffer_pool bp where ds.set_id=bp.lo_setid(+)and ds.set_id freelists Freelist blocks free lists groups File Header Block look at extent allocationThere is a hot block,eliminate the hot bloc

35、k#.60BBW:StatspackTop 5 Timed Events Avg%Total wait CallEvent Waits Time(s)(ms)Time-buffer busy waits 5,832 263 45 28.2log file parallel write 248 125 505 13.4read by other session 902 103 114 11.1db file parallel write 2,166 94 43 10.1db file sequential read 653 81 125 8.7Class Waits Wait Time(s)Av

36、g Time(ms)-file header block 264 203 769data block 6,070 162 27undo header 355 0 1segment header 44 0 1fails to find Object#.61BBW:ASHFindsObjectBlock TypeSQL StatementCNT OBJ OTYPE SQL_ID BLOCK_TYPE TBS-2 BBW_INDEX_VAL_I INDEX 635xhydd6fzgg segment header SYSTEM 2 0 635xhydd6fzgg usn 5 header UNDOT

37、BS1 3 0 1hsb81ypyrfs5 file header block UNDOTBS1 32 BBW_INDEX_VAL_I INDEX 1hsb81ypyrfs5 data block SYSTEM 33 BBW_INDEX_VAL_I INDEX 6avm49ys4k7t6 data block SYSTEM 34 BBW_INDEX_VAL_I INDEX 5wqps1quuxqr4 data block SYSTEM#.62BBW:OEM#.63Solutions#.64BBW Block Typesselect rownum n,ws.classselect rownum

38、n,ws.classfrom v$waitstatfrom v$waitstat;NAME P1 P2 P3-buffer busy waits file#block#class#select*from v$event_namewhere name=buffer busy waits N CLASS -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 leve

39、l 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 blockNote:Before 10g,P3 was BBW typeIf P3 in 100,110,120,130 then readNow“read by other session”Else Write,P3 in 200,210,220,230,231#.65Joining ASH with v$wait

40、statselect o.object_name obj,o.object_type otype,ash.SQL_ID,w.classfrom v$active_session_history ash,(select rownum class#,class from v$waitstat)w,all_objects owhere event=buffer busy waits and w.class#(+)=ash.p3 and o.object_id(+)=ash.CURRENT_OBJ#Order by sample_time;OBJ OTYPE SQL_ID CLASS-TOTO1 TA

41、BLE 8gz51m9hg5yuf data blockTOTO1 TABLE 8gz51m9hg5yuf data blockTOTO1 TABLE 8gz51m9hg5yuf segment headerTOTO1 TABLE 8gz51m9hg5yuf data block#.66Alternative to ASH:AWRselect to_char(BEGIN_INTERVAL_TIME,DD-MON HH:MI),o.name,s.BUFFER_BUSY_WAITS_DELTAfrom dba_hist_seg_stat s,dba_hist_snapshot sn,obj$owh

42、ere BUFFER_BUSY_WAITS_DELTA 100 and sn.snap_id=s.snap_id and o.obj#=s.obj#;TO_CHAR(BEGI NAME BUFFER_BUSY_WAITS_DELTA-11-JAN 10:21 TOTO1 58447#.67Example:BBW with InsertConcurrent inserts will insert into the same blockEach session has to wait for the previous session to finish its writeUsually prett

43、y fastContention builds on highly concurrent applicationsLack of Free ListsNot Using ASSM(Automatic Segment Space Management)#.68Example:Lack of Free List S1S2S3S44 Sessions runningInsert into toto values(null,a);Commit;OBJN OTYPE FILEN BLOCKN SQL_ID BLOCK_TYPE-54962 TOTO1 TABLE 16 45012 8gz51m9hg5y

44、uf data block 54962 TOTO1 TABLE 16 161 8gz51m9hg5yuf segment header#.69Solution1:Free ListsS1S2S3S44 Sessions runningInsert into toto values(null,a);Commit;#.70Solution 2:ASSMMultiple Bitmap Blocks Track Free SpaceUnformattedUp to 25%FreeUp to 50%FreeUp to 75%FreeFullFree block chosen by Process IDP

45、ossibly instance#for RAC#.71Solution 2:ASSM#.72Tablespace Types:ASSMselect tablespace_name,extent_management LOCAL,allocation_type EXTENTS,segment_space_management ASSM,initial_extentfrom dba_tablespacesTABLESPACE_NAME LOCAL EXTENTS ASSM-SYSTEM LOCAL SYSTEM MANUALUNDOTBS1 LOCAL SYSTEM MANUALSYSAUX L

46、OCAL SYSTEM AUTOTEMP LOCAL UNIFORM MANUALUSERS LOCAL SYSTEM AUTOEXAMPLE LOCAL SYSTEM AUTODATA LOCAL SYSTEM MANUALcreate tablespace data2 datafile/d3/kyle/data2_01.dbf size 200Msegment space management auto;#.73BBW:ASSMConsider using Freelists instead of ASSMNormally waits on ASSM blocks should be to

47、o small to warrant using FreelistsASSM is easier,automatically managed1st level bmb2nd level bmb 3rd level bmb#.74BBW on IndexIndexSession 1Session 2Session 3Increasing index key creates a hot spot on the leading index leafOBJN OTYPE FILEN BLOCKN SQL_ID BLOCK_TYPE-BBW_INDEX_INDEX 1 113599 97dgthz60u

48、28d data block 1Use Reverse Key indexesBreaks Index scansHash Partition IndexMore IOs per index access#.75BBW on Index:ADDM RecsAlso consider“reversing”the key#.76Example:BBW on RBSIF BBW happen on old style RBSClass#18Switch to UNDOOld style RBS,the DBA had to figure out#of RBS SegmentsWith UNDO,it

49、 is automatically managedalter system set undo_management=auto scope=spfile;#.77BBW and RBS SegsOBJN OTYPE FILEN BLOCKN SQL_ID BLOCK_TYPE-54962 TOTO1 TABLE 16 45012 8gz51m9hg5yuf data block 54962 TOTO1 TABLE 16 161 8gz51m9hg5yuf segment header0 14 9 8gz51m9hg5yuf 870 14 9 8gz51m9hg5yuf 87Select CURR

50、ENT_OBJ#|o.object_name objn,o.object_type otype,CURRENT_FILE#filen,CURRENT_BLOCK#blockn,ash.SQL_ID,w.class|to_char(ash.p3)block_typefrom v$active_session_history ash,(select rownum class#,class from v$waitstat)w,all_objects owhere event=buffer busy waits and w.class#(+)=ash.p3 and o.object_id(+)=ash

侵权处理QQ:3464097650--上传资料QQ:3464097650

【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。


163文库-Www.163Wenku.Com |网站地图|