数据库CH--(10)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

CHAPTER10StorageandFileStructureThischapterpresentsbasicfilestructureconcepts.Thechapterreallyconsistsoftwoparts—thefirstdealingwithrelationaldatabases,andthesecondwithobject-orienteddatabases.Thesecondpartcanbeomittedwithoutlossofcontinuityforlaterchapters.Manycomputerscienceundergraduateshavecoveredsomeofthematerialinthischapterinapriorcourseondatastructuresoronfilestructures.Evenifstudents’backgroundsareprimarilyindatastructures,thischapterisstillimpor-tantsinceitaddressesdatastructureissuesastheypertaintodiskstorage.Buffermanagementissues,coveredinSection10.8.1shouldbefamiliartostudentswhohavetakenanoperatingsystemscourse.However,therearedatabase-specificas-pectsofbuffermanagementthatmakethissectionworthwhileevenforstudentswithanoperatingsystembackground.Exercises10.10Listthephysicalstoragemediaavailableonthecomputersyouuserou-tinely.Givethespeedwithwhichdatacanbeaccessedoneachmedium.Answer:Youranswerwillbebasedonthecomputersandstoragemediathatyouuse.Typicalexampleswouldbeharddisk,CDandDVDdisks,andflashmemoryintheformofUSBkeys,memorycardsorsolidstatedisks.Thefollowingtableshowsthetypicaltransferspeedsfortheabovemen-tionedstoragemedia,asofearly2010.StorageMediaSpeed(inMB/s)CDDrive8DVDDrive20USBKeys30MemoryCards1-40HardDisk100SolidStateDisks1009192Chapter10StorageandFileStructureNotethatspeedsofflashmemorycardscanvarysignificantly,withsomelowendcardsgivinglowtransferspeeds,althoughbetteronesgivemuchhighertransferspeeds.10.11Howdoestheremappingofbadsectorsbydiskcontrollersaffectdata-retrievalrates?Answer:Remappingofbadsectorsbydiskcontrollersdoesreducedataretrievalratesbecauseofthelossofsequentialityamongstthesectors.Butthatisbetterthanthelossofdataincaseofnoremapping!10.12RAIDsystemstypicallyallowyoutoreplacefaileddiskswithoutstoppingaccesstothesystem.Thus,thedatainthefaileddiskmustberebuiltandwrittentothereplacementdiskwhilethesystemisinoperation.WhichoftheRAIDlevelsyieldstheleastamountofinterferencebetweentherebuildandongoingdiskaccesses?Explainyouranswer.Answer:RAIDlevel1(mirroring)istheonewhichfacilitatesrebuildingofafaileddiskwithminimuminterferencewiththeon-goingdiskaccesses.Thisisbecauserebuildinginthiscaseinvolvescopyingdatafromjustthefaileddisk’smirror.IntheotherRAIDlevels,rebuildinginvolvesreadingtheentirecontentsofalltheotherdisks.10.13Whatisscrubbing,inthecontextofRAIDsystems,andwhyisscrubbingimportant?Answer:Successfullywrittensectorswhicharesubsequentlydamaged,butwherethedamagehasnotbeendetected,arereferredtoaslatentsectorerrors.InRAIDsystems,latenterrorscanleadtodatalossevenonasinglediskfailure,ifthelatenterrorexistsononeoftheotherdisks.Diskscrubbingisabackgroundprocessthatreadsdisksectorsduringidleperiods,withthegoalofdetectinglatentsectorerrors.Ifasectorerrorisfound,thesectorcaneitherberewrittenifthemediahasnotbeendamaged,orremappedtoasparesectorinthedisk.ThedatainthesectorcanberecoveredfromtheotherdisksintheRAIDarray.10.14Inthevariable-lengthrecordrepresentation,anullbitmapisusedtoindicateifanattributehasthenullvalue.a.Forvariablelengthfields,ifthevalueisnull,whatwouldbestoredintheoffsetandlengthfields?b.Insomeapplications,tupleshaveaverylargenumberofattributes,mostofwhicharenull.Canyoumodifytherecordrepresentationsuchthattheonlyoverheadforanullattributeisthesinglebitinthenullbitmap.Answer:a.Itdoesnotmatteronwhatwestoreintheoffsetandlengthfieldssinceweareusinganullbitmaptoidentifynullentries.Butitwouldmakesensetosettheoffsetandlengthtozerotoavoidhavingarbitraryvalues.Exercises93b.Weshouldbeabletolocatethenullbitmapandtheoffsetandlengthvaluesofnon-nullattributesusingthenullbitmap.Thiscanbedonebystoringthenullbitmapatthebeginningandthenfornon-nullattributes,storethevalue(forfixedsizeattributes),oroffsetandlengthvalues(forvariablesizedattributes)inthesameorderasinthebitmap,followedbythevaluesfornon-nullvariablesizedattributes.Thisrepresentationisspaceefficientbutneedsextraworktoretrievetheattributes.10.15Explainwhytheallocationofrecordstoblocksaffectsdatabase-systemperformancesignificantly.Answer:Ifweallocaterelatedrecordstoblocks,wecanoftenretrievemost,orall,oftherequestedrecordsbyaquerywithonediskaccess.Diskaccessestendtobethebottlenecksindatabases;sincethisallocationstrategyreducesthenumberofdiskaccessesforagivenoperation,itsignificantlyimprovesperformance.10.16Ifpossible,determinethebuffer-managementstrategyusedbytheoperat-ingsystemrunningonyourlocalcomputersystemandwhatmechanismsitprovidestocontrolreplacementofpages.Discusshowthecontrolonreplacementthatitprovideswouldbeusefulfortheimplementationofdatabasesystems.Answer:ThetypicalOSusesvariantsofLRU,whicharecheapertoimplementthanLRU,forbufferreplacement.LRUanditsvariantsareoftenabadstrategyfordatabases.AsexplainedinSection10.8.2ofthetext,MRUisthebeststrategyfornestedloopjoin.Ingeneralnosinglestrategyhandlesallscenarioswell,andthedatabasesystemshouldbeabletomanageitsownbuffercacheforwhichthereplacementpolicytakesintoaccountalltheperformancerelatedissues.Manyoperatingsystemsprovidemechanismstolockpagesinmemory,whichcanbeusedtoensurebufferpagesstayinme

1 / 5
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功