Documente Academic
Documente Profesional
Documente Cultură
***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:
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:
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:
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
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
Listprefetching
Listprefetch,orlistsequentialprefetch,isawaytoaccessdatapagesefficientlyeven whenthedatapagesneededarenotcontiguous.Listprefetchcanbeusedinconjunction witheithersingleormultipleindexaccess.
andthefollowingsearchcriteria:
WHERENAMEBETWEEN'A'and'I'
Ifthedataisnotclusteredaccordingtothisindex,listprefetchincludesastepthatsorts thelistofRIDsobtainedfromtheindexscan.