Академический Документы
Профессиональный Документы
Культура Документы
htmupdated5/13/2013
FiguresshowninthesenotesarefromOracleDatabaseConcepts11gRelease2
Module1OracleArchitecture
Objectives
ThesenotesintroducetheOracleserverarchitecture.Thearchitectureincludesphysical
components,memorycomponents,processes,andlogicalstructures.
PrimaryArchitectureComponents
ThefigureshownabovedetailstheOraclearchitecture.
Oracleserver:AnOracleserverincludesanOracleInstanceandanOracledatabase.
AnOracledatabaseincludesseveraldifferenttypesoffiles:datafiles,controlfiles,redolog
filesandarchiveredologfiles.TheOracleserveralsoaccessesparameterfilesand
passwordfiles.
Thissetoffileshasseveralpurposes.
oOneistoenablesystemuserstoprocessSQLstatements.
oAnotheristoimprovesystemperformance.
oStillanotheristoensurethedatabasecanberecoveredifthereisasoftware/hardware
failure.
Thedatabaseservermustmanagelargeamountsofdatainamultiuserenvironment.
Theservermustmanageconcurrentaccesstothesamedata.
Theservermustdeliverhighperformance.Thisgenerallymeansfastresponsetimes.
Oracleinstance:AnOracleInstanceconsistsoftwodifferentsetsofcomponents:
Thefirstcomponentsetisthesetofbackgroundprocesses(PMON,SMON,RECO,DBW0,
LGWR,CKPT,D000andothers).
oThesewillbecoveredlaterindetaileachbackgroundprocessisacomputerprogram.
oTheseprocessesperforminput/outputandmonitorotherOracleprocessestoprovide
goodperformanceanddatabasereliability.
ThesecondcomponentsetincludesthememorystructuresthatcomprisetheOracle
instance.
oWhenaninstancestartsup,amemorystructurecalledtheSystemGlobalArea(SGA)is
allocated.
oAtthispointthebackgroundprocessesalsostart.
AnOracleInstanceprovidesaccesstooneandonlyoneOracledatabase.
Oracledatabase:AnOracledatabaseconsistsoffiles.
Sometimesthesearereferredtoasoperatingsystemfiles,buttheyareactuallydatabase
filesthatstorethedatabaseinformationthatafirmororganizationneedsinordertooperate.
Theredologfilesareusedtorecoverthedatabaseintheeventofapplicationprogram
failures,instancefailuresandotherminorfailures.
Thearchivedredologfilesareusedtorecoverthedatabaseifadiskfails.
Otherfilesnotshowninthefigureinclude:
oTherequiredparameterfilethatisusedtospecifyparametersforconfiguringanOracle
instancewhenitstartsup.
oTheoptionalpasswordfileauthenticatesspecialusersofthedatabasetheseare
termedprivilegedusersandincludedatabaseadministrators.
oAlertandTraceLogFilesthesefilesstoreinformationabouterrorsandactionstaken
thataffecttheconfigurationofthedatabase.
Userandserverprocesses:Theprocessesshowninthefigurearecalleduserandserver
processes.TheseprocessesareusedtomanagetheexecutionofSQLstatements.
ASharedServerProcesscansharememoryandvariableprocessingformultipleuser
processes.
ADedicatedServerProcessmanagesmemoryandvariablesforasingleuserprocess.
ThisfigurefromtheOracleDatabaseAdministrationGuideprovidesanotherwayofviewingthe
SGA.
ConnectingtoanOracleInstanceCreatingaSession
SystemuserscanconnecttoanOracledatabasethroughSQLPlusorthroughanapplication
programliketheInternetDeveloperSuite(theprogrambecomesthesystemuser).Thisconnection
enablesuserstoexecuteSQLstatements.
TheactofconnectingcreatesacommunicationpathwaybetweenauserprocessandanOracle
Server.Asisshowninthefigureabove,theUserProcesscommunicateswiththeOracleServer
throughaServerProcess.TheUserProcessexecutesontheclientcomputer.TheServerProcess
executesontheservercomputer,andactuallyexecutesSQLstatementssubmittedbythesystem
user.
ThefigureshowsaonetoonecorrespondencebetweentheUserandServerProcesses.Thisis
calledaDedicatedServerconnection.AnalternativeconfigurationistouseaSharedServer
wheremorethanoneUserProcesssharesaServerProcess.
Sessions:WhenauserconnectstoanOracleserver,thisistermedasession.TheUserGlobal
Areaissessionmemoryandthesememorystructuresaredescribedlaterinthisdocument.The
sessionstartswhentheOracleservervalidatestheuserforconnection.Thesessionendswhenthe
userlogsout(disconnects)oriftheconnectionterminatesabnormally(networkfailureorclient
computerfailure).
Ausercantypicallyhavemorethanoneconcurrentsession,e.g.,theusermayconnectusing
SQLPlusandalsoconnectusingInternetDeveloperSuitetoolsatthesametime.Thelimitof
concurrentsessionconnectionsiscontrolledbytheDBA.
IfasystemusersattemptstoconnectandtheOracleServerisnotrunning,thesystemuser
receivestheOracleNotAvailableerrormessage.
PhysicalStructureDatabaseFiles
Aswasnotedabove,anOracledatabaseconsistsofphysicalfiles.Thedatabaseitselfhas:
Datafilesthesecontaintheorganization'sactualdata.
Redologfilesthesecontainachronologicalrecordofchangesmadetothedatabase,and
enablerecoverywhenfailuresoccur.
Controlfilestheseareusedtosynchronizealldatabaseactivitiesandarecoveredinmore
detailinalatermodule.
Otherkeyfilesasnotedaboveinclude:
Parameterfiletherearetwotypesofparameterfiles.
oTheinit.orafile(alsocalledthePFILE)isastaticparameterfile.Itcontainsparameters
thatspecifyhowthedatabaseinstanceistostartup.Forexample,someparameters
willspecifyhowtoallocatememorytothevariouspartsofthesystemglobalarea.
oThespfile.oraisadynamicparameterfile.Italsostoresparameterstospecifyhowto
startupadatabasehowever,itsparameterscanbemodifiedwhilethedatabaseis
running.
Passwordfilespecifieswhich*special*usersareauthenticatedtostartup/shutdownan
OracleInstance.
Archivedredologfilesthesearecopiesoftheredologfilesandarenecessaryforrecovery
inanonline,transactionprocessingenvironmentintheeventofadiskfailure.
MemoryManagementandMemoryStructures
OracleDatabaseMemoryManagement
Memorymanagementfocusistomaintainoptimalsizesformemorystructures.
Memoryismanagedbasedonmemoryrelatedinitializationparameters.
Thesevaluesarestoredintheinit.orafileforeachdatabase.
Threebasicoptionsformemorymanagementareasfollows:
Automaticmemorymanagement:
oDBAspecifiesthetargetsizeforinstancememory.
oThedatabaseinstanceautomaticallytunestothetargetmemorysize.
oDatabaseredistributesmemoryasneededbetweentheSGAandtheinstancePGA.
Automaticsharedmemorymanagement:
oThismanagementmodeispartiallyautomated.
oDBAspecifiesthetargetsizefortheSGA.
oDBAcanoptionallysetanaggregatetargetsizeforthePGAormanagingPGAwork
areasindividually.
Manualmemorymanagement:
oInsteadofsettingthetotalmemorysize,theDBAsetsmanyinitializationparametersto
managecomponentsoftheSGAandinstancePGAindividually.
IfyoucreateadatabasewithDatabaseConfigurationAssistant(DBCA)andchoosethebasic
installationoption,thenautomaticmemorymanagementisthedefault.
Thememorystructuresincludethreeareasofmemory:
SystemGlobalArea(SGA)thisisallocatedwhenanOracleInstancestartsup.
ProgramGlobalArea(PGA)thisisallocatedwhenaServerProcessstartsup.
UserGlobalArea(UGA)thisisallocatedwhenauserconnectstocreateasession.
SystemGlobalArea
TheSGAisaread/writememoryareathatstoresinformationsharedbyalldatabaseprocessesand
byallusersofthedatabase(sometimesitiscalledtheSharedGlobalArea).
oThisinformationincludesbothorganizationaldataandcontrolinformationusedbytheOracle
Server.
oTheSGAisallocatedinmemoryandvirtualmemory.
oThesizeoftheSGAcanbeestablishedbyaDBAbyassigningavaluetotheparameter
SGA_MAX_SIZEintheparameterfilethisisanoptionalparameter.
TheSGAisallocatedwhenanOracleinstance(database)isstartedupbasedonvaluesspecifiedin
theinitializationparameterfile(eitherPFILEorSPFILE).
TheSGAhasthefollowingmandatorymemorystructures:
DatabaseBufferCache
RedoLogBuffer
JavaPool
StreamsPool
SharedPoolincludestwocomponents:
oLibraryCache
oDataDictionaryCache
Otherstructures(forexample,lockandlatchmanagement,statisticaldata)
AdditionaloptionalmemorystructuresintheSGAinclude:
LargePool
TheSHOWSGASQLcommandwillshowyoutheSGAmemoryallocations.
ThisisarecentclipoftheSGAfortheDBORCLdatabaseatSIUE.
InordertoexecuteSHOWSGAyoumustbeconnectedwiththespecialprivilegeSYSDBA
(whichisonlyavailabletouseraccountsthataremembersoftheDBALinuxgroup).
SQL>connect/assysdba
Connected.
SQL>showsga
TotalSystemGlobalArea1610612736bytes
FixedSize2084296bytes
VariableSize1006633528bytes
DatabaseBuffers587202560bytes
RedoBuffers14692352bytes
EarlyversionsofOracleusedaStaticSGA.Thismeantthatifmodificationstomemory
managementwererequired,thedatabasehadtobeshutdown,modificationsweremadetothe
init.oraparameterfile,andthenthedatabasehadtoberestarted.
Oracle11gusesaDynamicSGA.Memoryconfigurationsforthesystemglobalareacanbemade
withoutshuttingdownthedatabaseinstance.TheDBAcanresizetheDatabaseBufferCacheand
SharedPooldynamically.
Severalinitializationparametersaresetthataffecttheamountofrandomaccessmemorydedicated
totheSGAofanOracleInstance.Theseare:
SGA_MAX_SIZE:Thisoptionalparameterisusedtosetalimitontheamountofvirtual
memoryallocatedtotheSGAatypicalsettingmightbe1GBhowever,ifthevaluefor
SGA_MAX_SIZEintheinitializationparameterfileorserverparameterfileislessthanthesum
thememoryallocatedforallcomponents,eitherexplicitlyintheparameterfileorbydefault,at
thetimetheinstanceisinitialized,thenthedatabaseignoresthesettingforSGA_MAX_SIZE.
Foroptimalperformance,theentireSGAshouldfitinrealmemorytoeliminatepagingto/from
diskbytheoperatingsystem.
DB_CACHE_SIZE:Thisoptionalparameterisusedtotunetheamountmemoryallocatedto
theDatabaseBufferCacheinstandarddatabaseblocks.Blocksizesvaryamongoperating
systems.TheDBORCLdatabaseuses8KBblocks.Thetotalblocksinthecachedefaultsto
48MBonLINUX/UNIXand52MBonWindowsoperatingsystems.
LOG_BUFFER:ThisoptionalparameterspecifiesthenumberofbytesallocatedfortheRedo
LogBuffer.
SHARED_POOL_SIZE:Thisoptionalparameterspecifiesthenumberofbytesofmemory
allocatedtosharedSQLandPL/SQL.Thedefaultis16MB.Iftheoperatingsystemisbased
ona64bitconfiguration,thenthedefaultsizeis64MB.
LARGE_POOL_SIZE:ThisisanoptionalmemoryobjectthesizeoftheLargePooldefaults
tozero.Iftheinit.oraparameterPARALLEL_AUTOMATIC_TUNINGissettoTRUE,thenthe
defaultsizeisautomaticallycalculated.
JAVA_POOL_SIZE:Thisisanotheroptionalmemoryobject.Thedefaultis24MBof
memory.
ThesizeoftheSGAcannotexceedtheparameterSGA_MAX_SIZEminusthecombinationofthe
sizeoftheadditionalparameters,DB_CACHE_SIZE,LOG_BUFFER,SHARED_POOL_SIZE,
LARGE_POOL_SIZE,andJAVA_POOL_SIZE.
MemoryisallocatedtotheSGAascontiguousvirtualmemoryinunitstermedgranules.Granule
sizedependsontheestimatedtotalsizeoftheSGA,whichaswasnotedabove,dependsonthe
SGA_MAX_SIZEparameter.Granulesaresizedasfollows:
IftheSGAislessthan1GBintotal,eachgranuleis4MB.
IftheSGAisgreaterthan1GBintotal,eachgranuleis16MB.
GranulesareassignedtotheDatabaseBufferCache,SharedPool,JavaPool,andothermemory
structures,andthesememorycomponentscandynamicallygrowandshrink.Usingcontiguous
memoryimprovessystemperformance.Theactualnumberofgranulesassignedtooneofthese
memorycomponentscanbedeterminedbyqueryingthedatabaseviewnamed
V$BUFFER_POOL.
GranulesareallocatedwhentheOracleserverstartsadatabaseinstanceinordertoprovide
memoryaddressingspacetomeettheSGA_MAX_SIZEparameter.Theminimumis3granules:
oneeachforthefixedSGA,DatabaseBufferCache,andSharedPool.Inpractice,you'llfindthe
SGAisallocatedmuchmorememorythanthis.TheSELECTstatementshownbelowshowsa
current_sizeof1,152granules.
SELECTname,block_size,current_size,prev_size,prev_buffers
FROMv$buffer_pool
NAMEBLOCK_SIZECURRENT_SIZEPREV_SIZEPREV_BUFFERS
DEFAULT819256057671244
ForadditionalinformationonthedynamicSGAsizing,enrollinOracle'sOracle11gDatabase
PerformanceTuningcourse.
ProgramGlobalArea(PGA)
APGAis:
anonsharedmemoryregionthatcontainsdataandcontrolinformationexclusivelyforuseby
anOracleprocess.
APGAiscreatedbyOracleDatabasewhenanOracleprocessisstarted.
OnePGAexistsforeachServerProcessandeachBackgroundProcess.Itstoresdataand
controlinformationforasingleServerProcessorasingleBackgroundProcess.
Itisallocatedwhenaprocessiscreatedandthememoryisscavengedbytheoperating
systemwhentheprocessterminates.ThisisNOTasharedpartofmemoryonePGAto
eachprocessonly.
ThecollectionofindividualPGAsisthetotalinstancePGA,orinstancePGA.
DatabaseinitializationparameterssetthesizeoftheinstancePGA,notindividualPGAs.
TheProgramGlobalAreaisalsotermedtheProcessGlobalArea(PGA)andisapartofmemory
allocatedthatisoutsideoftheOracleInstance.
ThecontentofthePGAvaries,butasshowninthefigureabove,generallyincludesthefollowing:
PrivateSQLArea:StoresinformationforaparsedSQLstatementstoresbindvariablevalues
andruntimememoryallocations.AusersessionissuingSQLstatementshasaPrivateSQLArea
thatmaybeassociatedwithaSharedSQLAreaifthesameSQLstatementisbeingexecutedby
morethanonesystemuser.ThisoftenhappensinOLTPenvironmentswheremanyusersare
executingandusingthesameapplicationprogram.
oDedicatedServerenvironmentthePrivateSQLAreaislocatedintheProgramGlobal
Area.
oSharedServerenvironmentthePrivateSQLAreaislocatedintheSystemGlobalArea.
SessionMemory:Memorythatholdssessionvariablesandothersessioninformation.
SQLWorkAreas:Memoryallocatedforsort,hashjoin,bitmapmerge,andbitmapcreatetypes
ofoperations.
oOracle9iandlaterversionsenableautomaticsizingoftheSQLWorkAreasbysettingthe
WORKAREA_SIZE_POLICY=AUTOparameter(thisisthedefault!)and
PGA_AGGREGATE_TARGET=n(wherenissomeamountofmemoryestablishedbythe
DBA).However,theDBAcanlettheOracleDBMSdeterminetheappropriateamountof
memory.
UserGlobalArea
TheUserGlobalAreaissessionmemory.
AsessionthatloadsaPL/SQLpackageintomemoryhasthepackagestatestoredtotheUGA.
Thepackagestateisthesetofvaluesstoredinallthepackagevariablesataspecifictime.The
statechangesasprogramcodethevariables.Bydefault,packagevariablesareuniquetoand
persistforthelifeofthesession.
TheOLAPpagepoolisalsostoredintheUGA.ThispoolmanagesOLAPdatapages,whichare
equivalenttodatablocks.ThepagepoolisallocatedatthestartofanOLAPsessionandreleased
attheendofthesession.AnOLAPsessionopensautomaticallywheneverauserqueriesa
dimensionalobjectsuchasacube.
Note:OracleOLAPisamultidimensionalanalyticengineembeddedinOracleDatabase
11g.OracleOLAPcubesdeliversophisticatedcalculationsusingsimpleSQLqueries
producingresultswithspeedofthoughtresponsetimes.
TheUGAmustbeavailabletoadatabasesessionforthelifeofthesession.Forthisreason,the
UGAcannotbestoredinthePGAwhenusingasharedserverconnectionbecausethePGAis
specifictoasingleprocess.Therefore,theUGAisstoredintheSGAwhenusingsharedserver
connections,enablinganysharedserverprocessaccesstoit.Whenusingadedicatedserver
connection,theUGAisstoredinthePGA.
AutomaticSharedMemoryManagement
PriortoOracle10G,aDBAhadtomanuallyspecifySGAComponentsizesthroughtheinitialization
parameters,suchasSHARED_POOL_SIZE,DB_CACHE_SIZE,JAVA_POOL_SIZE,and
LARGE_POOL_SIZEparameters.
AutomaticSharedMemoryManagementenablesaDBAtospecifythetotalSGAmemory
availablethroughtheSGA_TARGETinitializationparameter.TheOracleDatabaseautomatically
distributesthismemoryamongvarioussubcomponentstoensuremosteffectivememoryutilization.
TheDBORCLdatabaseSGA_TARGETissetintheinitDBORCL.orafile:
sga_target=1610612736
WithautomaticSGAmemorymanagement,thedifferentSGAcomponentsareflexiblysizedto
adapttotheSGAavailable.
SettingasingleparametersimplifiestheadministrationtasktheDBAonlyspecifiestheamountof
SGAmemoryavailabletoaninstancetheDBAcanforgetaboutthesizesofindividual
components.Nooutofmemoryerrorsaregeneratedunlessthesystemhasactuallyrunoutof
memory.Nomanualtuningeffortisneeded.
TheSGA_TARGETinitializationparameterreflectsthetotalsizeoftheSGAandincludesmemory
forthefollowingcomponents:
FixedSGAandotherinternalallocationsneededbytheOracleDatabaseinstance
Thelogbuffer
Thesharedpool
TheJavapool
Thebuffercache
Thekeepandrecyclebuffercaches(ifspecified)
Nonstandardblocksizebuffercaches(ifspecified)
TheStreamsPool
IfSGA_TARGETissettoavaluegreaterthanSGA_MAX_SIZEatstartup,thenthe
SGA_MAX_SIZEvalueisbumpeduptoaccommodateSGA_TARGET.
WhenyousetavalueforSGA_TARGET,OracleDatabase11gautomaticallysizesthemost
commonlyconfiguredcomponents,including:
Thesharedpool(forSQLandPL/SQLexecution)
TheJavapool(forJavaexecutionstate)
Thelargepool(forlargeallocationssuchasRMANbackupbuffers)
Thebuffercache
ThereareafewSGAcomponentswhosesizesarenotautomaticallyadjusted.TheDBAmust
specifythesizesofthesecomponentsexplicitly,iftheyareneededbyanapplication.Such
componentsare:
Keep/Recyclebuffercaches(controlledbyDB_KEEP_CACHE_SIZEand
DB_RECYCLE_CACHE_SIZE)
Additionalbuffercachesfornonstandardblocksizes(controlledbyDB_nK_CACHE_SIZE,n=
{2,4,8,16,32})
StreamsPool(controlledbythenewparameterSTREAMS_POOL_SIZE)
ThegranulesizethatiscurrentlybeingusedfortheSGAforeachcomponentcanbeviewedinthe
viewV$SGAINFO.Thesizeofeachcomponentandthetimeandtypeofthelastresizeoperation
performedoneachcomponentcanbeviewedintheviewV$SGA_DYNAMIC_COMPONENTS.
SQL>select*fromv$sgainfo
More...
NAMEBYTESRES
FixedSGASize2084296No
RedoBuffers14692352No
BufferCacheSize587202560Yes
SharedPoolSize956301312Yes
LargePoolSize16777216Yes
JavaPoolSize33554432Yes93
StreamsPoolSize0Yes
GranuleSize16777216No
MaximumSGASize1610612736No
StartupoverheadinSharedPool67108864No
FreeSGAMemoryAvailable0
11rowsselected.
SharedPool
TheSharedPoolisamemorystructurethatissharedbyallsystemusers.
Itcachesvarioustypesofprogramdata.Forexample,thesharedpoolstoresparsedSQL,
PL/SQLcode,systemparameters,anddatadictionaryinformation.
Thesharedpoolisinvolvedinalmosteveryoperationthatoccursinthedatabase.For
example,ifauserexecutesaSQLstatement,thenOracleDatabaseaccessestheshared
pool.
Itconsistsofbothfixedandvariablestructures.
Thevariablecomponentgrowsandshrinksdependingonthedemandsplacedonmemory
sizebysystemusersandapplicationprograms.
MemorycanbeallocatedtotheSharedPoolbytheparameterSHARED_POOL_SIZEinthe
parameterfile.Thedefaultvalueofthisparameteris8MBon32bitplatformsand64MBon64bit
platforms.Increasingthevalueofthisparameterincreasestheamountofmemoryreservedforthe
sharedpool.
YoucanalterthesizeofthesharedpooldynamicallywiththeALTERSYSTEMSETcommand.An
examplecommandisshowninthefigurebelow.Youmustkeepinmindthatthetotalmemory
allocatedtotheSGAissetbytheSGA_TARGETparameter(andmayalsobelimitedbythe
SGA_MAX_SIZEifitisset),andsincetheSharedPoolispartoftheSGA,youcannotexceedthe
maximumsizeoftheSGA.ItisrecommendedtoletOracleoptimizetheSharedPoolsize.
TheSharedPoolstoresthemostrecentlyexecutedSQLstatementsanduseddatadefinitions.This
isbecausesomesystemusersandapplicationprogramswilltendtoexecutethesameSQL
statementsoften.Savingthisinformationinmemorycanimprovesystemperformance.
TheSharedPoolincludesseveralcacheareasdescribedbelow.
LibraryCache
MemoryisallocatedtotheLibraryCachewheneveranSQLstatementisparsedoraprogramunit
iscalled.ThisenablesstorageofthemostrecentlyusedSQLandPL/SQLstatements.
IftheLibraryCacheistoosmall,theLibraryCachemustpurgestatementdefinitionsinordertohave
spacetoloadnewSQLandPL/SQLstatements.Actualmanagementofthismemorystructureis
throughaLeastRecentlyUsed(LRU)algorithm.ThismeansthattheSQLandPL/SQL
statementsthatareoldestandleastrecentlyusedarepurgedwhenmorestoragespaceisneeded.
TheLibraryCacheiscomposedoftwomemorysubcomponents:
SharedSQL:Thisstores/sharestheexecutionplanandparsetreeforSQLstatements,as
wellasPL/SQLstatementssuchasfunctions,packages,andtriggers.Ifasystemuser
executesanidenticalstatement,thenthestatementdoesnothavetobeparsedagaininorder
toexecutethestatement.
PrivateSQLArea:Withasharedserver,eachsessionissuingaSQLstatementhasaprivate
SQLareainitsPGA.
oEachuserthatsubmitsthesamestatementhasaprivateSQLareapointingtothe
samesharedSQLarea.
oManyprivateSQLareasinseparatePGAscanbeassociatedwiththesameshared
SQLarea.
oThisfiguredepictstwodifferentclientprocessesissuingthesameSQLstatement
theparsedsolutionisalreadyintheSharedSQLArea.
DataDictionaryCache
TheDataDictionaryCacheisamemorystructurethatcachesdatadictionaryinformationthathas
beenrecentlyused.
Thiscacheisnecessarybecausethedatadictionaryisaccessedsooften.
Informationaccessedincludesuseraccountinformation,datafilenames,tabledescriptions,
userprivileges,andotherinformation.
ThedatabaseservermanagesthesizeoftheDataDictionaryCacheinternallyandthesizedepends
onthesizeoftheSharedPoolinwhichtheDataDictionaryCacheresides.Ifthesizeistoosmall,
thenthedatadictionarytablesthatresideondiskmustbequeriedoftenforinformationandthiswill
slowdownperformance.
ServerResultCache
TheServerResultCacheholdsresultsetsandnotdatablocks.Theserverresultcachecontainsthe
SQLqueryresultcacheandPL/SQLfunctionresultcache,whichsharethesameinfrastructure.
SQLQueryResultCache
Thiscachestorestheresultsofqueriesandqueryfragments.
Usingthecacheresultsforfuturequeriestendstoimproveperformance.
Forexample,supposeanapplicationrunsthesameSELECTstatementrepeatedly.Ifthe
resultsarecached,thenthedatabasereturnsthemimmediately.
Inthisway,thedatabaseavoidstheexpensiveoperationofrereadingblocksandrecomputing
results.
PL/SQLFunctionResultCache
ThePL/SQLFunctionResultCachestoresfunctionresultsets.
Withoutcaching,1000callsofafunctionat1secondpercallwouldtake1000seconds.
Withcaching,1000functioncallswiththesameinputscouldtake1secondtotal.
Goodcandidatesforresultcachingarefrequentlyinvokedfunctionsthatdependonrelatively
staticdata.
PL/SQLfunctioncodecanspecifythatresultsbecached.
BufferCaches
Anumberofbuffercachesaremaintainedinmemoryinordertoimprovesystemresponsetime.
DatabaseBufferCache
TheDatabaseBufferCacheisafairlylargememoryobjectthatstorestheactualdatablocksthat
areretrievedfromdatafilesbysystemqueriesandotherdatamanipulationlanguagecommands.
Thepurposeistooptimizephysicalinput/outputofdata.
WhenDatabaseSmartFlashCache(flashcache)isenabled,partofthebuffercachecanreside
intheflashcache.
Thisbuffercacheextensionisstoredonaflashdiskdevice,whichisasolidstatestorage
devicethatusesflashmemory.
Thedatabasecanimproveperformancebycachingbuffersinflashmemoryinsteadofreading
frommagneticdisk.
DatabaseSmartFlashCacheisavailableonlyinSolarisandOracleEnterpriseLinux.
AquerycausesaServerProcesstolookfordata.
ThefirstlookisintheDatabaseBufferCachetodetermineiftherequestedinformation
happenstoalreadybelocatedinmemorythustheinformationwouldnotneedtobe
retrievedfromdiskandthiswouldspeedupperformance.
IftheinformationisnotintheDatabaseBufferCache,theServerProcessretrievesthe
informationfromdiskandstoresittothecache.
Keepinmindthatinformationreadfromdiskisreadablockatatime,NOTarowatatime,
becauseadatabaseblockisthesmallestaddressablestoragespaceondisk.
DatabaseblocksarekeptintheDatabaseBufferCacheaccordingtoaLeastRecentlyUsed(LRU)
algorithmandareagedoutofmemoryifabuffercacheblockisnotusedinordertoprovidespace
fortheinsertionofnewlyneededdatabaseblocks.
Therearethreebufferstates:
Unusedabufferisavailableforuseithasneverbeenusedoriscurrentlyunused.
Cleanabufferthatwasusedearlierthedatahasbeenwrittentodisk.
Dirtyabufferthathasmodifieddatathathasnotbeenwrittentodisk.
Eachbufferhasoneoftwoaccessmodes:
Pinnedabufferispinnedsoitdoesnotageoutofmemory.
Free(unpinned).
Thebuffersinthecacheareorganizedintwolists:
thewritelistand,
theleastrecentlyused(LRU)list.
Thewritelist(alsocalledawritequeue)holdsdirtybuffersthesearebuffersthatholdthatdata
thathasbeenmodified,buttheblockshavenotbeenwrittenbacktodisk.
TheLRUlistholdsunused,freecleanbuffers,pinnedbuffers,andfreedirtybuffersthathavenot
yetbeenmovedtothewritelist.Freecleanbuffersdonotcontainanyusefuldataandare
availableforuse.Pinnedbuffersarecurrentlybeingaccessed.
WhenanOracleprocessaccessesabuffer,theprocessmovesthebuffertothemostrecently
used(MRU)endoftheLRUlistthiscausesdirtybufferstoagetowardtheLRUendoftheLRU
list.
WhenanOracleuserprocessneedsadatarow,itsearchesforthedatainthedatabasebuffer
cachebecausememorycanbesearchedmorequicklythanharddiskcanbeaccessed.Ifthedata
rowisalreadyinthecache(acachehit),theprocessreadsthedatafrommemoryotherwisea
cachemissoccursanddatamustbereadfromharddiskintothedatabasebuffercache.
Beforereadingadatablockintothecache,theprocessmustfirstfindafreebuffer.Theprocess
searchestheLRUlist,startingattheLRUendofthelist.Thesearchcontinuesuntilafreebufferis
foundoruntilthesearchreachesthethresholdlimitofbuffers.
EachtimeauserprocessfindsadirtybufferasitsearchestheLRU,thatbufferismovedtothewrite
listandthesearchforafreebuffercontinues.
Whenauserprocessfindsafreebuffer,itreadsthedatablockfromdiskintothebufferandmoves
thebuffertotheMRUendoftheLRUlist.
IfanOracleuserprocesssearchesthethresholdlimitofbufferswithoutfindingafreebuffer,the
processstopssearchingtheLRUlistandsignalstheDBWnbackgroundprocesstowritesomeof
thedirtybufferstodisk.Thisfreesupsomebuffers.
DatabaseBufferCacheBlockSize
Theblocksizeforadatabaseissetwhenadatabaseiscreatedandisdeterminedbytheinit.ora
parameterfileparameternamedDB_BLOCK_SIZE.
Typicalblocksizesare2KB,4KB,8KB,16KB,and32KB.
ThesizeofblocksintheDatabaseBufferCachematchestheblocksizeforthedatabase.
TheDBORCLdatabaseusesan8KBblocksize.
Thisfigureshowsthattheuseofnonstandardblocksizesresultsinmultipledatabasebuffer
cachememoryallocations.
Becausetablespacesthatstoreoracletablescanusedifferent(nonstandard)blocksizes,therecan
bemorethanoneDatabaseBufferCacheallocatedtomatchblocksizesinthecachewiththeblock
sizesinthenonstandardtablespaces.
ThesizeoftheDatabaseBufferCachescanbecontrolledbytheparametersDB_CACHE_SIZE
andDB_nK_CACHE_SIZEtodynamicallychangethememoryallocatedtothecacheswithout
restartingtheOracleinstance.
YoucandynamicallychangethesizeoftheDatabaseBufferCachewiththeALTERSYSTEM
commandliketheoneshownhere:
ALTERSYSTEMSETDB_CACHE_SIZE=96M
YoucanhavetheOracleServergatherstatisticsabouttheDatabaseBufferCachetohelpyousizeit
toachieveanoptimalworkloadforthememoryallocation.Thisinformationisdisplayedfromthe
V$DB_CACHE_ADVICEview.Inorderforstatisticstobegathered,youcandynamicallyalterthe
systembyusingtheALTERSYSTEMSETDB_CACHE_ADVICE(OFF,ON,READY)command.
However,gatheringstatisticsonsystemperformancealwaysincurssomeoverheadthatwillslow
downsystemperformance.
SQL>ALTERSYSTEMSETdb_cache_advice=ON
Systemaltered.
SQL>DESCV$DB_cache_advice
NameNull?Type
IDNUMBER
NAMEVARCHAR2(20)
BLOCK_SIZENUMBER
ADVICE_STATUSVARCHAR2(3)
SIZE_FOR_ESTIMATENUMBER
SIZE_FACTORNUMBER
BUFFERS_FOR_ESTIMATENUMBER
ESTD_PHYSICAL_READ_FACTORNUMBER
ESTD_PHYSICAL_READSNUMBER
ESTD_PHYSICAL_READ_TIMENUMBER
ESTD_PCT_OF_DB_TIME_FOR_READSNUMBER
ESTD_CLUSTER_READSNUMBER
ESTD_CLUSTER_READ_TIMENUMBER
SQL>SELECTname,block_size,advice_statusFROMv$db_cache_advice
NAMEBLOCK_SIZEADV
DEFAULT8192ON
<morerowswilldisplay>
21rowsselected.
SQL>ALTERSYSTEMSETdb_cache_advice=OFF
Systemaltered.
KEEPBufferPool
Thispoolretainsblocksinmemory(datafromtables)thatarelikelytobereusedthroughoutdaily
processing.Anexamplemightbeatablecontainingusernamesandpasswordsoravalidation
tableofsometype.
TheDB_KEEP_CACHE_SIZEparametersizestheKEEPBufferPool.
RECYCLEBufferPool
Thispoolisusedtostoretabledatathatisunlikelytobereusedthroughoutdailyprocessingthus
thedatablocksarequicklyremovedfrommemorywhennotneeded.
TheDB_RECYCLE_CACHE_SIZEparametersizestheRecycleBufferPool.
RedoLogBuffer
TheRedoLogBuffermemoryobjectstoresimagesofallchangesmadetodatabaseblocks.
Databaseblockstypicallystoreseveraltablerowsoforganizationaldata.Thismeansthatifa
singlecolumnvaluefromonerowinablockischanged,theblockimageisstored.Changes
includeINSERT,UPDATE,DELETE,CREATE,ALTER,orDROP.
LGWRwritesredosequentiallytodiskwhileDBWnperformsscatteredwritesofdatablocksto
disk.
oScatteredwritestendtobemuchslowerthansequentialwrites.
oBecauseLGWRenableuserstoavoidwaitingforDBWntocompleteitsslowwrites,the
databasedeliversbetterperformance.
TheRedoLogBufferasacircularbufferthatisreusedoverandover.Asthebufferfillsup,copies
oftheimagesarestoredtotheRedoLogFilesthatarecoveredinmoredetailinalatermodule.
LargePool
TheLargePoolisanoptionalmemorystructurethatprimarilyrelievesthememoryburdenplaced
ontheSharedPool.TheLargePoolisusedforthefollowingtasksifitisallocated:
AllocatingspaceforsessionmemoryrequirementsfromtheUserGlobalAreawhereaShared
Serverisinuse.
Transactionsthatinteractwithmorethanonedatabase,e.g.,adistributeddatabasescenario.
BackupandrestoreoperationsbytheRecoveryManager(RMAN)process.
oRMANusesthisonlyiftheBACKUP_DISK_IO=nandBACKUP_TAPE_IO_SLAVE=
TRUEparametersareset.
oIftheLargePoolistoosmall,memoryallocationforbackupwillfailandmemorywillbe
allocatedfromtheSharedPool.
Parallelexecutionmessagebuffersforparallelserveroperations.The
PARALLEL_AUTOMATIC_TUNING=TRUEparametermustbeset.
TheLargePoolsizeissetwiththeLARGE_POOL_SIZEparameterthisisnotadynamic
parameter.ItdoesnotuseanLRUlisttomanagememory.
JavaPool
TheJavaPoolisanoptionalmemoryobject,butisrequiredifthedatabasehasOracleJava
installedandinuseforOracleJVM(JavaVirtualMachine).
ThesizeissetwiththeJAVA_POOL_SIZEparameterthatdefaultsto24MB.
TheJavaPoolisusedformemoryallocationtoparseJavacommandsandtostoredata
associatedwithJavacommands.
StoringJavacodeanddataintheJavaPoolisanalogoustoSQLandPL/SQLcodecachedin
theSharedPool.
StreamsPool
ThispoolstoresdataandcontrolstructurestosupporttheOracleStreamsfeatureofOracle
EnterpriseEdition.
OracleSteamsmanagessharingofdataandeventsinadistributedenvironment.
ItissizedwiththeparameterSTREAMS_POOL_SIZE.
IfSTEAMS_POOL_SIZEisnotsetoriszero,thesizeofthepoolgrowsdynamically.
Processes
YouneedtounderstandthreedifferenttypesofProcesses:
UserProcess:StartswhenadatabaseuserrequeststoconnecttoanOracleServer.
ServerProcess:EstablishestheConnectiontoanOracleInstancewhenaUserProcess
requestsconnectionmakestheconnectionfortheUserProcess.
BackgroundProcesses:ThesestartwhenanOracleInstanceisstartedup.
ClientProcess
InordertouseOracle,youmustconnecttothedatabase.Thismustoccurwhetheryou'reusing
SQLPlus,anOracletoolsuchasDesignerorForms,oranapplicationprogram.Theclientprocess
isalsotermedtheuserprocessinsomeOracledocumentation.
ThisgeneratesaUserProcess(amemoryobject)thatgeneratesprogrammaticcallsthroughyour
userinterface(SQLPlus,IntegratedDeveloperSuite,orapplicationprogram)thatcreatesasession
andcausesthegenerationofaServerProcessthatiseitherdedicatedorshared.
ServerProcess
AServerProcessisthegobetweenforaClientProcessandtheOracleInstance.
DedicatedServerenvironmentthereisasingleServerProcesstoserveeachClient
Process.
SharedServerenvironmentaServerProcesscanserveseveralUserProcesses,although
withsomeperformancereduction.
Allocationofserverprocessinadedicatedenvironmentversusasharedenvironmentis
coveredinfurtherdetailintheOracle11gDatabasePerformanceTuningcourseofferedby
OracleEducation.
BackgroundProcesses
Asisshownhere,therearebothmandatory,optional,andslavebackgroundprocessesthatare
startedwheneveranOracleInstancestartsup.Thesebackgroundprocessesserveallsystem
users.Wewillcovermandatoryprocessindetail.
MandatoryBackgroundProcesses
ProcessMonitorProcess(PMON)
SystemMonitorProcess(SMON)
DatabaseWriterProcess(DBWn)
LogWriterProcess(LGWR)
CheckpointProcess(CKPT)
ManageabilityMonitorProcesses(MMONandMMNL)
RecoverProcess(RECO)
OptionalProcesses
ArchiverProcess(ARCn)
CoordinatorJobQueue(CJQ0)
Dispatcher(numbernnn)(Dnnn)
Others
Thisquerywilldisplayallbackgroundprocessesrunningtoserveadatabase:
SELECTPNAME
FROMV$PROCESS
WHEREPNAMEISNOTNULL
ORDERBYPNAME
PMON
TheProcessMonitor(PMON)monitorsotherbackgroundprocesses.
Itisacleanuptypeofprocessthatcleansupafterfailedprocesses.
Examplesincludethedroppingofauserconnectionduetoanetworkfailureortheabnormal
termination(ABEND)ofauserapplicationprogram.
Itcleansupthedatabasebuffercacheandreleasesresourcesthatwereusedbyafaileduser
process.
Itdoesthetasksshowninthefigurebelow.
SMON
TheSystemMonitor(SMON)doessystemlevelcleanupduties.
Itisresponsibleforinstancerecoverybyapplyingentriesintheonlineredologfilestothe
datafiles.
OtherprocessescancallSMONwhenitisneeded.
Italsoperformsotheractivitiesasoutlinedinthefigureshownbelow.
IfanOracleInstancefails,allinformationinmemorynotwrittentodiskislost.SMONisresponsible
forrecoveringtheinstancewhenthedatabaseisstartedupagain.Itdoesthefollowing:
RollsforwardtorecoverdatathatwasrecordedinaRedoLogFile,butthathadnotyetbeen
recordedtoadatafilebyDBWn.SMONreadstheRedoLogFilesandappliesthechangesto
thedatablocks.Thisrecoversalltransactionsthatwerecommittedbecausethesewere
writtentotheRedoLogFilespriortosystemfailure.
Opensthedatabasetoallowsystemuserstologon.
Rollsbackuncommittedtransactions.
SMONalsodoeslimitedspacemanagement.Itcombines(coalesces)adjacentareasoffreespace
inthedatabase'sdatafilesfortablespacesthataredictionarymanaged.
Italsodeallocatestemporarysegmentstocreatefreespaceinthedatafiles.
DBWn(alsocalledDBWRinearlierOracleVersions)
TheDatabaseWriterwritesmodifiedblocksfromthedatabasebuffercachetothedatafiles.
Onedatabasewriterprocess(DBW0)issufficientformostsystems.
ADBAcanconfigureupto20DBWnprocesses(DBW0throughDBW9andDBWathrough
DBWj)inordertoimprovewriteperformanceforasystemthatmodifiesdataheavily.
TheinitializationparameterDB_WRITER_PROCESSESspecifiesthenumberofDBWn
processes.
ThepurposeofDBWnistoimprovesystemperformancebycachingwritesofdatabaseblocksfrom
theDatabaseBufferCachebacktodatafiles.
Blocksthathavebeenmodifiedandthatneedtobewrittenbacktodiskaretermed"dirty
blocks."
TheDBWnalsoensuresthatthereareenoughfreebuffersintheDatabaseBufferCacheto
serviceServerProcessesthatmaybereadingdatafromdatafilesintotheDatabaseBuffer
Cache.
Performanceimprovesbecausebydelayingwritingchangeddatabaseblocksbacktodisk,a
ServerProcessmayfindthedatathatisneededtomeetaUserProcessrequestalready
residinginmemory!
DBWnwritestodatafileswhenoneoftheseeventsoccursthatisillustratedinthefigure
below.
LGWR
TheLogWriter(LGWR)writescontentsfromtheRedoLogBuffertotheRedoLogFilethatisin
use.
ThesearesequentialwritessincetheRedoLogFilesrecorddatabasemodificationsbasedon
theactualtimethatthemodificationtakesplace.
LGWRactuallywritesbeforetheDBWnwritesandonlyconfirmsthataCOMMIToperation
hassucceededwhentheRedoLogBuffercontentsaresuccessfullywrittentodisk.
LGWRcanalsocalltheDBWntowritecontentsoftheDatabaseBufferCachetodisk.
TheLGWRwritesaccordingtotheeventsillustratedinthefigureshownbelow.
CKPT
TheCheckpoint(CPT)processwritesinformationtoupdatethedatabasecontrolfilesandheaders
ofdatafiles.
AcheckpointidentifiesapointintimewithregardtotheRedoLogFileswhereinstance
recoveryistobeginshoulditbenecessary.
ItcantellDBWntowriteblockstodisk.
Acheckpointistakenataminimum,onceeverythreeseconds.
Thinkofacheckpointrecordasastartingpointforrecovery.DBWnwillhavecompletedwritingall
buffersfromtheDatabaseBufferCachetodiskpriortothecheckpoint,thusthoserecordswillnot
requirerecovery.Thisdoesthefollowing:
EnsuresmodifieddatablocksinmemoryareregularlywrittentodiskCKPTcancallthe
DBWnprocessinordertoensurethisanddoessowhenwritingacheckpointrecord.
ReducesInstanceRecoverytimebyminimizingtheamountofworkneededforrecoverysince
onlyRedoLogFileentriesprocessedsincethelastcheckpointrequirerecovery.
Causesallcommitteddatatobewrittentodatafilesduringdatabaseshutdown.
IfaRedoLogFilefillsupandaswitchismadetoanewRedoLogFile(thisiscoveredinmoredetail
inalatermodule),theCKPTprocessalsowritescheckpointinformationintotheheadersofthe
datafiles.
Checkpointinformationwrittentocontrolfilesincludesthesystemchangenumber(theSCNisa
numberstoredinthecontrolfileandintheheadersofthedatabasefilesthatareusedtoensurethat
allfilesinthesystemaresynchronized),locationofwhichRedoLogFileistobeusedforrecovery,
andotherinformation.
CKPTdoesnotwritedatablocksorredoblockstodiskitcallsDBWnandLGWRasnecessary.
MMONandMMNL
TheManageabilityMonitorProcess(MMNO)performstasksrelatedtotheAutomaticWorkload
Repository(AWR)arepositoryofstatisticaldataintheSYSAUXtablespace(seefigurebelow)
forexample,MMONwriteswhenametricviolatesitsthresholdvalue,takingsnapshots,and
capturingstatisticsvalueforrecentlymodifiedSQLobjects.
TheManageabilityMonitorLiteProcess(MMNL)writesstatisticsfromtheActiveSessionHistory
(ASH)bufferintheSGAtodisk.MMNLwritestodiskwhentheASHbufferisfull.
Theinformationstoredbytheseprocessesisusedforperformancetuningwesurveyperformance
tuninginalatermodule.
RECO
TheRecovererProcess(RECO)isusedtoresolvefailuresofdistributedtransactionsina
distributeddatabase.
ConsideradatabasethatisdistributedontwoserversoneinSt.LouisandoneinChicago.
Further,thedatabasemaybedistributedonserversoftwodifferentoperatingsystems,e.g.
LINUXandWindows.
TheRECOprocessofanodeautomaticallyconnectstootherdatabasesinvolvedinanin
doubtdistributedtransaction.
WhenRECOreestablishesaconnectionbetweenthedatabases,itautomaticallyresolvesall
indoubttransactions,removingfromeachdatabase'spendingtransactiontableanyrowsthat
correspondtotheresolvedtransactions.
OptionalBackgroundProcesses
OptionalBackgroundProcessDefinition:
ARCn:ArchiverOneormorearchiverprocessescopytheonlineredologfilestoarchival
storagewhentheyarefulloralogswitchoccurs.
CJQ0:CoordinatorJobQueueThisisthecoordinatorofjobqueueprocessesforaninstance.
ItmonitorstheJOB$table(tableofjobsinthejobqueue)andstartsjobqueueprocesses(Jnnn)
asneededtoexecutejobsTheJnnnprocessesexecutejobrequestscreatedbythe
DBMS_JOBSpackage.
Dnnn:Dispatchernumber"nnn",forexample,D000wouldbethefirstdispatcherprocess
Dispatchersareoptionalbackgroundprocesses,presentonlywhenthesharedserver
configurationisused.Sharedserverisdiscussedinyourreadingsonthetopic"Configuring
OraclefortheSharedServer".
FBDA:FlashbackDataArchiverProcessThisarchiveshistoricalrowsoftrackedtablesinto
FlashbackDataArchives.WhenatransactioncontainingDMLonatrackedtablecommits,this
processstoresthepreimageoftherowsintotheFlashbackDataArchive.Italsokeepsmetadata
onthecurrentrows.FBDAautomaticallymanagestheflashbackdataarchiveforspace,
organization,andretention
Ofthese,youwillmostoftenuseARCn(archiver)whenyouautomaticallyarchiveredologfile
information(coveredinalatermodule).
ARCn
WhiletheArchiver(ARCn)isanoptionalbackgroundprocess,wecoveritinmoredetailbecauseit
isalmostalwaysusedforproductionsystemsstoringmissioncriticalinformation.
TheARCnprocessmustbeusedtorecoverfromlossofaphysicaldiskdriveforsystemsthat
are"busy"withlotsoftransactionsbeingcompleted.
Itperformsthetaskslistedbelow.
WhenaRedoLogFilefillsup,OracleswitchestothenextRedoLogFile.
TheDBAcreatesseveraloftheseandthedetailsofcreatingthemarecoveredinalater
module.
IfallRedoLogFilesfillup,thenOracleswitchesbacktothefirstoneandusesthemina
roundrobinfashionbyoverwritingonesthathavealreadybeenused.
OverwrittenRedoLogFileshaveinformationthat,onceoverwritten,islostforever.
ARCHIVELOGMode:
IfARCnisinwhatistermedARCHIVELOGmode,thenastheRedoLogFilesfillup,theyare
individuallywrittentoArchivedRedoLogFiles.
LGWRdoesnotoverwriteaRedoLogFileuntilarchivinghascompleted.
Committeddataisnotlostforeverandcanberecoveredintheeventofadiskfailure.
OnlythecontentsoftheSGAwillbelostifanInstancefails.
InNOARCHIVELOGMode:
TheRedoLogFilesareoverwrittenandnotarchived.
Recoverycanonlybemadetothelastfullbackupofthedatabasefiles.
Allcommittedtransactionsafterthelastfullbackuparelost,andyoucanseethatthiscould
costthefirmalotof$$$.
WhenrunninginARCHIVELOGmode,theDBAisresponsibletoensurethattheArchivedRedoLog
Filesdonotconsumeallavailablediskspace!Usuallyaftertwocompletebackupsaremade,any
ArchivedRedoLogFilesforpriorbackupsaredeleted.
SlaveProcesses
Slaveprocessesarebackgroundprocessesthatperformworkonbehalfofotherprocesses.
Innn:I/OslaveprocessessimulateasynchronousI/Oforsystemsanddevicesthatdonot
supportit.InasynchronousI/O,thereisnotimingrequirementfortransmission,enablingother
processestostartbeforethetransmissionhasfinished.
Forexample,assumethatanapplicationwrites1000blockstoadiskonanoperatingsystem
thatdoesnotsupportasynchronousI/O.
Eachwriteoccurssequentiallyandwaitsforaconfirmationthatthewritewassuccessful.
Withasynchronousdisk,theapplicationcanwritetheblocksinbulkandperformotherwork
whilewaitingforaresponsefromtheoperatingsystemthatallblockswerewritten.
ParallelQuerySlavesInparallelexecutionorparallelprocessing,multipleprocesseswork
togethersimultaneouslytorunasingleSQLstatement.
Bydividingtheworkamongmultipleprocesses,OracleDatabasecanrunthestatementmore
quickly.
Forexample,fourprocesseshandlefourdifferentquartersinayearinsteadofoneprocess
handlingallfourquartersbyitself.
Parallelexecutionreducesresponsetimefordataintensiveoperationsonlargedatabases
suchasdatawarehouses.Symmetricmultiprocessing(SMP)andclusteredsystemgainthe
largestperformancebenefitsfromparallelexecutionbecausestatementprocessingcanbe
splitupamongmultipleCPUs.ParallelexecutioncanalsobenefitcertaintypesofOLTPand
hybridsystems.
LogicalStructure
ItishelpfultounderstandhowanOracledatabaseisorganizedintermsofalogicalstructurethatis
usedtoorganizephysicalobjects.
Tablespace:AnOracledatabasemustalwaysconsistofatleasttwotablespaces(SYSTEMand
SYSAUX),althoughatypicalOracledatabasewillmultipletablespaces.
Atablespaceisalogicalstoragefacility(alogicalcontainer)forstoringobjectssuchastables,
indexes,sequences,clusters,andotherdatabaseobjects.
Eachtablespacehasatleastonephysicaldatafilethatactuallystoresthetablespaceatthe
operatingsystemlevel.Alargetablespacemayhavemorethanonedatafileallocatedfor
storingobjectsassignedtothattablespace.
Atablespacebelongstoonlyonedatabase.
Tablespacescanbebroughtonlineandtakenofflineforpurposesofbackupandmanagement,
exceptfortheSYSTEMtablespacethatmustalwaysbeonline.
Tablespacescanbeineitherreadonlyorreadwritestatus.
Datafile:Tablespacesarestoredindatafileswhicharephysicaldiskobjects.
Adatafilecanonlystoreobjectsforasingletablespace,butatablespacemayhavemorethan
onedatafilethishappenswhenadiskdrivedevicefillsupandatablespaceneedstobe
expanded,thenitisexpandedtoanewdiskdrive.
TheDBAcanchangethesizeofadatafiletomakeitsmallerorlater.Thefilecanalsogrowin
sizedynamicallyasthetablespacegrows.
Segment:Whenlogicalstorageobjectsarecreatedwithinatablespace,forexample,anemployee
table,asegmentisallocatedtotheobject.
Obviouslyatablespacetypicallyhasmanysegments.
Asegmentcannotspantablespacesbutcanspandatafilesthatbelongtoasingletablespace.
Extent:Eachobjecthasonesegmentwhichisaphysicalcollectionofextents.
Extentsaresimplycollectionsofcontiguousdiskstorageblocks.Alogicalstorageobject
suchasatableorindexalwaysconsistsofatleastoneextentideallytheinitialextent
allocatedtoanobjectwillbelargeenoughtostorealldatathatisinitiallyloaded.
Asatableorindexgrows,additionalextentsareaddedtothesegment.
ADBAcanaddextentstosegmentsinordertotuneperformanceofthesystem.
Anextentcannotspanadatafile.
Block:TheOracleServermanagesdataatthesmallestunitinwhatistermedablockordata
block.Dataareactuallystoredinblocks.
Aphysicalblockisthesmallestaddressablelocationonadiskdriveforread/writeoperations.
AnOracledatablockconsistsofoneormorephysicalblocks(operatingsystemblocks)sothedata
block,iflargerthananoperatingsystemblock,shouldbeanevenmultipleoftheoperatingsystem
blocksize,e.g.,iftheLinuxoperatingsystemblocksizeis2Kor4K,thentheOracledatablock
shouldbe2K,4K,8K,16K,etcinsize.ThisoptimizesI/O.
Thedatablocksizeissetatthetimethedatabaseiscreatedandcannotbechanged.Itissetwith
theDB_BLOCK_SIZEparameter.Themaximumdatablocksizedependsontheoperatingsystem.
Thus,theOracledatabasearchitectureincludesbothlogicalandphysicalstructuresasfollows:
Physical:ControlfilesRedoLogFilesDatafilesOperatingSystemBlocks.
Logical:TablespacesSegmentsExtentsDataBlocks.
SQLStatementProcessing
SQLStatementsareprocesseddifferentlydependingonwhetherthestatementisaquery,data
manipulationlanguage(DML)toupdate,insert,ordeletearow,ordatadefinitionlanguage(DDL)to
writeinformationtothedatadictionary.
Processingaquery:
Parse:
oSearchforidenticalstatementintheSharedSQLArea.
oChecksyntax,objectnames,andprivileges.
oLockobjectsusedduringparse.
oCreateandstoreexecutionplan.
Bind:Obtainsvaluesforvariables.
Execute:Processstatement.
Fetch:Returnrowstouserprocess.
ProcessingaDMLstatement:
Parse:Sameastheparsephaseusedforprocessingaquery.
Bind:Sameasthebindphaseusedforprocessingaquery.
Execute:
oIfthedataandundoblocksarenotalreadyintheDatabaseBufferCache,theserver
processreadsthemfromthedatafilesintotheDatabaseBufferCache.
oTheserverprocessplaceslocksontherowsthataretobemodified.Theundoblockis
usedtostorethebeforeimageofthedata,sothattheDMLstatementscanberolled
backifnecessary.
oThedatablocksrecordthenewvaluesofthedata.
oTheserverprocessrecordsthebeforeimagetotheundoblockandupdatesthedata
block.BothofthesechangesaremadeintheDatabaseBufferCache.Anychanged
blocksintheDatabaseBufferCachearemarkedasdirtybuffers.Thatis,buffersthat
arenotthesameasthecorrespondingblocksonthedisk.
oTheprocessingofaDELETEorINSERTcommandusessimilarsteps.Thebeforeimage
foraDELETEcontainsthecolumnvaluesinthedeletedrow,andthebeforeimageofan
INSERTcontainstherowlocationinformation.
ProcessingaDDLstatement:
TheexecutionofDDL(DataDefinitionLanguage)statementsdiffersfromtheexecutionof
DML(DataManipulationLanguage)statementsandqueries,becausethesuccessofaDDL
statementrequireswriteaccesstothedatadictionary.
Forthesestatements,parsingactuallyincludesparsing,datadictionarylookup,and
execution.Transactionmanagement,sessionmanagement,andsystemmanagementSQL
statementsareprocessedusingtheparseandexecutestages.Toreexecutethem,simply
performanotherexecute.
ENDOFNOTES