Sunteți pe pagina 1din 7

Bufferpoolmanagement =================== Abufferpoolismemoryusedtocachetableandindexdatapagesastheyarebeingread fromdisk,orbeingmodified.Thebufferpoolimprovesdatabasesystemperformanceby allowingdatatobeaccessedfrommemoryinsteadoffromdisk.Becausememoryaccess ismuchfasterthandiskaccess,thelessoftenthedatabasemanagerneedstoreadfromor writetoadisk,thebettertheperformance.Becausemostdatamanipulationtakesplacein bufferpools, **Onlylargeobjectsandlongfielddataarenotmanipulatedinabufferpool. Whenanapplicationaccessesarowofatableforthefirsttime,thedatabasemanager placesthepagecontainingthatrowinthebufferpool.Thenexttimeanyapplication requestsdata,thedatabasemanagerlooksforitinthebufferpool.Iftherequesteddatais inthebufferpool,itcanberetrievedwithoutdiskaccess,resultinginfasterperformance. ***Memoryisallocatedforthebufferpoolwhenadatabaseisactivatedorwhenthe firstapplicationconnectstothedatabase.

***Bufferpoolscanalsobecreated,dropped,andresizedwhilethedatabaseismanager isrunning.IfyouusetheIMMEDIATEkeywordwhenyouusetheALTER BUFFERPOOLstatementtoincreasethesizeofthebufferpool,memoryisallocatedas soonasyouenterthecommandifthememoryisavailable.Ifthememoryisunavailable, thechangeoccurswhenallapplicationsaredisconnectedandthedatabaseisreactivated. Ifyoudecreasethesizeofthebufferpool,memoryisdeallocatedatcommitaltime. Whenallapplicationsaredisconnected,thebufferpoolmemoryisdeallocated. Note: Toreducethenecessityofincreasingthesizeofthedbheap9databaseconfiguration parameterwhenbufferpoolsizesincrease,nearlyallbufferpoolmemory,which includespage9descriptors,bufferpooldescriptors,andthehashtables,comesoutofthe databasesharedmemoryset9andissizedautomatically. Toensurethatanappropriatebufferpoolisavailableinallcircumstances,DB2(R)creates smallbufferpools,onewitheachpagesize:4K,8K,16K,and32K.Thesizeofeach bufferpoolis16pages.Thesebufferpoolsarehiddenfromtheuser.Theyarenotpresent inthesystemcatalogsorinthebufferpoolsystemfiles.Youcannotuseoralterthem directly,butDB2usesthesebufferpoolsinthefollowingcircumstances:

9Whenabufferpooloftherequiredpagesizeisinactivebecauseinsufficient memorywasavailabletocreate9itafteraCREATEBUFFERPOOLstatement wasexecutedwiththeIMMEDIATEkeyword.99 Amessageiswrittentotheadministrationnotificationlog.If9necessary,table spacesareremappedtoahiddenbufferpool.Performance9mightbedrastically reduced.

Whentheordinarybufferpoolscannotbebroughtupduringadatabaseconnect Thisproblemislikelytohaveaseriouscause,suchasoutofmemorycondition. AlthoughDB2willbefullyfunctionalbecauseofthehiddenbufferpools, performancewilldegradedrastically.Youshouldaddressthisproblem immediately.Youreceiveawarningwhenthisoccursandamessageiswrittento theadministrationnotificationlog.

Pagesremaininthebufferpooluntilthedatabaseisshutdown,oruntilthespace occupiedbyapageisrequiredforanotherpage.Thefollowingcriteriadeterminewhich pageisremovedtobringinanotherpage:


Howrecentlythepagewasreferenced Theprobabilitythatthepagewillbereferencedagainbythelastagentthatlooked atit Thetypeofdataonthepage Whetherthepagewaschangedinmemorybutnotwrittenouttodisk(Changed pagesarealwayswrittentodiskbeforebeingoverwritten.)

Inorderforpagestobeaccessedfrommemoryagain,changedpagesarenotremoved fromthebufferpoolaftertheyarewrittenouttodiskunlessthespaceisneeded. 9Whenyoucreateabufferpool,thedefaultpagesizeisthesizespecifiedwhenthe databasewascreated9unlessyouexplicitlyspecifyapagesizeotherthanthedefault pagesize.9Becausepagescanbereadintoabufferpoolonlyifthetablespacepagesize isthesameasthebufferpoolpagesize,9thepagesizeofyourtablespacesshould determinethepagesizethatyouspecifyforbufferpools.9Youcannotalterthepagesize ofthebufferpoolafteryoucreateit.9Youmustcreateanewbufferpoolwithadifferent pagesize. Note: On32bitplatformsthatrunWindows(R)NT,youcancreatelargebufferpoolsifyou haveenabledAddressWindowingExtensions(AWE)orAdvancedServerandData CenterServeronWindows2000.

Bufferpoolmanagementofdatapages
Pagesinthebufferpoolcanbeeitherinuseornot,andtheycanbedirtyorclean: 7 Inusepagesarecurrentlybeingreadorupdated.Whileapageisin7usebyan agent,itcanberead,butnotupdated,byotheragentsorprefetchers7inthe database.7 "Dirty"pagescontaindatathathasbeenchangedbuthasnotyet7beenwrittento disk.7 Afterachangedpageiswrittentodisk,itiscleanbutremainsinthe7bufferpool untilitsspaceisneededfornewpages.Cleanpagescanalso7bemigratedtoan associatedextendedstoragecache,ifoneisdefined.

Pagecleaneragents Inawelltunedsystem,itisusuallythepagecleaneragentsthatwritechangedor"dirty" pagestodisk.PagecleaneragentsperformI/Oasbackgroundprocessesandallow applicationstorunfasterbecausetheiragentscanperformactualtransactionwork.Page cleaneragentsaresometimesreferredtoasasynchronouspagecleanersorasynchronous bufferwritersbecausetheyarenotcoordinatedwiththeworkofotheragentsandwork onlywhenrequired. Toimproveperformanceinupdateintensiveworkloads,youmightwanttoconfigure morepagecleaneragents.Performancecanimproveifmorepagecleaneragentsare availabletowritedirtypagestodisk.Thisisparticularlytrueifsnapshotsrevealthat thereareasignificantnumberofsynchronousdatapageorindexpagewritesinrelation tothenumberofasynchronousdatapageorindexpagewrites. Pagecleaningandfastrecovery Ifmorepageshavebeenwrittentodisk,recoveryofthedatabaseisfasterafterasystem crashbecausethedatabasemanagercanrebuildmoreofthebufferpoolfromdiskinstead ofhavingtoreplaytransactionsfromthedatabaselogfiles. Thesizeofthelogthatmustbereadduringrecoveryisthedifferencebetweenthe locationofthefollowingrecordsinthelog:

Themostrecentlywrittenlogrecord Thelogrecordthatdescribestheoldestchangetodatainthebufferpool.

Thedefaultbehaviorofthepagecleanersisthatpagecleaningisperformedifthesizeof thelogthatwouldneedtobereplayedduringrecoveryexceedsthefollowingmaximum:

logfilsiz*softmax

where:

logfilsizrepresentsthesizeofthelogfiles softmaxrepresentsthepercentageoflogfilestoberecoveredfollowinga databasecrash.Forexample,ifthevalueofsoftmaxis250,then2.5logfileswill containthechangesthatneedtoberecoveredifacrashoccurs.

7Tominimizelogreadtimeduringrecovery,usethedatabasesystem7monitortotrack thenumberoftimesthatpagecleaningisperformed.The7systemmonitor pool_lsn_gap_clns(bufferpoollogspace7cleanerstriggered)monitorelementprovides thisinformationifyou7havenotenabledproactivepagecleaningforyourdatabase.If youhaveenabled7thisalternatepagecleaning,thisconditionshouldnotoccurandthe pool_lsn_gap_clnsmonitorelementisalways0. 7Thelog_held_by_dirty_pagesmonitor7elementcanbeusedtodetermineifthepage cleanersarenotcleaningenough7pagestomeettherecoverycriteriasetbytheuser.If log_held_by_dirty_pagesisconsistentlyandsignificantlygreaterthanlogfilsiz* softmax,theneithermorepagecleanersare7required,orsoftmaxneedstobeadjusted.

Prefetchingdataintothebufferpool
Prefetchingpagesmeansthatoneormorepagesareretrievedfromdiskinthe expectationthattheywillberequiredbyanapplication.Prefetchingindexanddatapages intothebufferpoolcanhelpimproveperformancebyreducingtheI/Owaittime.In addition,parallelI/Oenhancesprefetchingefficiency. Therearetwocategoriesofprefetching:

Sequentialprefetch:Amechanismthatreadsconsecutivepagesintothebuffer poolbeforethepagesarerequiredbytheapplication. Listprefetch:Sometimescalledlistsequentialprefetch.Prefetchesasetofnon consecutivedatapagesefficiently.

Thesetwomethodsofreadingdatapagesareinadditiontoanormalread.Anormalread isusedwhenonlyoneorafewconsecutivepagesareretrieved.Duringanormalread, onepageofdataistransferred.

Sequentialprefetching
ReadingseveralconsecutivepagesintothebufferpoolusingasingleI/Ooperationcan greatlyreduceyourapplicationoverhead.Inaddition,multipleparallelI/Ooperationsto readseveralrangesofpagesintothebufferpoolcanhelpreduceI/Owaittime. PrefetchingstartswhenthedatabasemanagerdeterminesthatsequentialI/Ois appropriateandthatprefetchingmightimproveperformance.Incasessuchastablescans andtablesorts,thedatabasemanagercaneasilydeterminethatsequentialprefetchwill improveI/Operformance.Inthesecases,thedatabasemanagerautomaticallystarts sequentialprefetch.Thefollowingexample,whichprobablyrequiresatablescan,would beagoodcandidateforsequentialprefetch:
SELECTNAMEFROMEMPLOYEE

ImplicationsofthePREFETCHSIZEfortablespaces Todefinethenumberofprefetchedpagesforeachtablespace,usethePREFETCHSIZE clauseineithertheCREATETABLESPACEorALTERTABLESPACEstatements.The valuethatyouspecifyismaintainedinthePREFETCHSIZEcolumnofthe SYSCAT.TABLESPACESsystemcatalogtable. 7ItisagoodpracticetoexplicitlysetthePREFETCHSIZE7valueasamultipleofthe numberoftablespacecontainers,thenumber7ofphysicaldisksundereachcontainer(if aRAIDdeviceisused)andthe7EXTENTSIZEvalueforyourtablespace,whichisthe numberofpagesthatthe7databasemanagerwritestoacontainerbeforeitusesa differentcontainer.7Forexample,iftheextentsizeis16pagesandthetablespacehas twocontainers,7youmightsettheprefetchquantityto32pages.Ifthereare5physical disks7percontainer,thenyoumightsettheprefetchquantityto160pages. Thedatabasemanagermonitorsbufferpoolusagetoensurethatprefetchingdoesnot removepagesfromthebufferpoolifanotherunitofworkneedsthem.Toavoid problems,thedatabasemanagercanlimitthenumberofprefetchedpagestolessthanyou specifyforthetablespace. Theprefetchsizecanhavesignificantperformanceimplications,particularlyforlarge tablescans.Usethedatabasesystemmonitorandothersystemmonitortoolstohelpyou tunePREFETCHSIZEforyourtablespaces.Youmightgatherinformationabout whether:

ThereareI/Owaitsforyourquery,usingmonitoringtoolsavailableforyour

operatingsystem. Prefetchisoccurring,bylookingatthepool_async_data_reads(bufferpool asynchronousdatareads)dataelementprovidedbythedatabasesystemmonitor.

IfthereareI/Owaitsandthequeryisprefetchingdata,youmightincreasethevalueof PREFETCHSIZE.IftheprefetcherisnotthecauseoftheI/Owait,increasingthe PREFETCHSIZEvaluewillnotimprovetheperformanceofyourquery. Inalltypesofprefetch,multipleI/Ooperationsmightbeperformedinparallelwhenthe prefetchsizeisamultipleoftheextentsizeforthetablespaceandtheextentsofthetable spaceareinseparatecontainers.Forbetterperformance,configurethecontainerstouse separatephysicaldevices. Sequentialdetection Insomecasesitisnotimmediatelyobviousthatsequentialprefetchwillimprove performance.Inthesecases,thedatabasemanagercanmonitorI/Oandactivate prefetchingifsequentialpagereadingisoccurring.Inthiscase,prefetchingisactivated anddeactivatedbythedatabasemanagerasappropriate.Thistypeofsequentialprefetch isknownassequentialdetectionandappliestobothindexanddatapages.Usethe seqdetectconfigurationparametertocontrolwhetherthedatabasemanagerperforms sequentialdetection. Forexample,ifsequentialdetectionisturnedon,thefollowingSQLstatementmight benefitfromsequentialprefetch:
SELECTNAMEFROMEMPLOYEE WHEREEMPNOBETWEEN100AND3000

Inthisexample,theoptimizermighthavestartedtoscanthetableusinganindexonthe EMPNOcolumn.Ifthetableishighlyclusteredwithrespecttothisindex,thenthedata pagereadswillbealmostsequentialandprefetchingmightimproveperformance,so datapageprefetchwilloccur. Indexpageprefetchmightalsooccurinthisexample.Ifmanyindexpagesmustbe examinedandthedatabasemanagerdetectsthatsequentialpagereadingoftheindex pagesisoccurring,thenindexpageprefetchingoccurs.

Listprefetching
Listprefetch,orlistsequentialprefetch,isawaytoaccessdatapagesefficientlyeven whenthedatapagesneededarenotcontiguous.Listprefetchcanbeusedinconjunction witheithersingleormultipleindexaccess.

Iftheoptimizerusesanindextoaccessrows,itcandeferreadingthedatapagesuntilall therowidentifiers(RIDs)havebeenobtainedfromtheindex.Forexample,theoptimizer couldperformanindexscantodeterminetherowsanddatapagestoretrieve,giventhe previouslydefinedindexIX1:


INDEXIX1:NAMEASC, DEPTASC, MGRDESC, SALARYDESC, YEARSASC

andthefollowingsearchcriteria:
WHERENAMEBETWEEN'A'and'I'

Ifthedataisnotclusteredaccordingtothisindex,listprefetchincludesastepthatsorts thelistofRIDsobtainedfromtheindexscan.

S-ar putea să vă placă și