Sunteți pe pagina 1din 7

6 System Architecture

In the following sections we discuss the main components of the Oracle DBMS (Version 7 !" architecture (Section 6 #" and the logical and physical data$ase structures (Sections 6 % and 6 &" 'e furthermore s(etch how S)* statements are processed (Section 6 +" and how data$ase o$,ects are created (Section 6 -"

6 # Storage Management and .rocesses

/he Oracle DBMS ser0er is $ased on a so1called Multi1Ser0er Architecture /he ser0er is responsi$le for processing all data$ase acti0ities such as the e2ecution of S)* statements3 user and resource management3 and storage management Although there is only one copy of the program code for the DBMS ser0er3 to each user connected to the ser0er logically a separate ser0er is assigned /he following figure illustrates the architecture of the Oracle DBMS consisting of storage structures3 processes3 and files
ServerProcess ServerProcess ServerProcess PGA PGA PGA Shared Pool Dictionary Cache Library Cache

System Global Area (SGA)


ServerBuffer Archive Log Buffer LG ! A!C" P#$% S#$% Bac&ground Processes DB ! PGA 'ser ( 'ser ) 'ser * 'ser n Process Database Datafiles !edo-Log +iles Control +iles Archive- and Bac&u, +iles !edo-LogBuffer

4igure +5 Oracle System Architecture -6 7ach time a data$ase is started on the ser0er (instance startup"3 a portion of the computer8s main memory is allocated3 the so1called System 9lo$al Area (S9A" /he S9A consists of the shared pool3 the data$ase $uffer3 and the redo1log $uffer 4urthermore3 se0eral $ac(ground processes are started /he com$ination of S9A and processes is called data$ase instance /he memory and processes associated with an instance are responsi$le for efficiently managing the data stored in the data$ase3 and to allow users accessing the data$ase concurrently /he Oracle ser0er can manage multiple instances3 typically each instance is associated with a particular application domain

/he S9A ser0es as that part of the memory where all data$ase operations occur If se0eral users connect to an instance at the same time3 they all share the S9A /he information stored in the S9A can $e su$di0ided into the following three caches Data$ase Buffer /he data$ase $uffer is a cache in the S9A used to hold the data $loc(s that are read from data files Bloc(s can contain ta$le data3 inde2 data etc Data $loc(s are modified in the data$ase $uffer Oracle manages the space a0aila$le in the data$ase $uffer $y using a least recently used (*:;" algorithm 'hen free space is needed in the $uffer3 the least recently used $loc(s will $e written out to the data files /he si<e of the data$ase $uffer has a ma,or impact on the o0erall performance of a data$ase :edo1*og1Buffer /his $uffer contains information a$out changes of data $loc(s in the data$ase $uffer 'hile the redo1log1$uffer is filled during data modifications3 the log writer process writes information a$out the modifications to the redo1log files /hese files are used after3 e g 3 a system crash3 in order to restore the data$ase (data$ase reco0ery" Shared .ool /he shared pool is the part of the S9A that is used $y all users /he main components of this pool are the dictionary cache and the li$rary cache Information a$out data$ase o$,ects is stored in the data dictionary ta$les 'hen information is needed $y the data$ase3 for e2ample3 to chec( whether a ta$le column specified in a =uery e2ists3 the dictionary ta$les are read and the data returned is stored in the dictionary cache >ote that all S)* statements re=uire accessing the data dictionary /hus (eeping rele0ant portions of the dictionary in the cache may increase the performance /he li$rary cache contains information a$out the most recently issued S)* commands such as the parse tree and =uery e2ecution plan If the same S)* statement is issued se0eral times3 it need not $e parsed again and all information a$out e2ecuting the statement can $e retrie0ed from the li$rary cache 4urther storage structures in the computer8s main memory are the log1archi0e $uffer (optional" and the .rogram 9lo$al Area (.9A" /he log1archi0e $uffer is used to temporarily cache redolog entries that are to $e archi0ed in special files /he .9A is the area in the memory that is used $y a single Oracle user process It contains the user8s conte2t area (cursors3 0aria$les etc "3 as well as process information /he memory in the .9A is not shara$le 4or each data$ase instance3 there is a set of processes /hese processes maintain and enforce the relationships $etween the data$ase8s physical structures and memory structures /he num$er -? of processes 0aries depending on the instance configuration One can distinguish $etween user processes and Oracle processes Oracle processes are typically $ac(ground processes that perform I@O operations at data$ase run1time

DB': /his process is responsi$le for managing the contents of the data$ase $uffer and the dictionary cache 4or this3 DB': writes modified data $loc(s to the data files /he process only writes $loc(s to the files if more $loc(s are going to $e read into the $uffer than free $loc(s e2ist *9': /his process manages writing the contents of the redo1log1$uffer to the redo1log files SMO> 'hen a data$ase instance is started3 the system monitor process performs instance reco0ery as needed (e g 3 after a system crash" It cleans up the data$ase from a$orted transactions and o$,ects in0ol0ed In particular3 this process is responsi$le for coalescing contiguous free e2tents to larger e2tents (space defragmentation3 see Section 6 %" .MO> /he process monitor process cleans up $ehind failed user processes and it also cleans up the resources used $y these processes *i(e SMO>3 .MO> wa(es up periodically to chec( whether it is needed A:AB (optional" /he *9': $ac(ground process writes to the redo1log files in a cyclic fashion Once the last redo1log file is filled3 *9': o0erwrites the contents of the first redo1log file It is possi$le to run a data$ase instance in the archi0e1log mode In this case the A:AB process copies redo1log entries to archi0e files $efore the entries are o0erwritten $y *9': /hus it is possi$le to restore the contents of the data$ase to any time after the archi0e1log mode was started ;S7: /he tas( of this process is to communicate with other processes started $y application programs such as S)*C.lus /he ;S7: process then is responsi$le for sending respecti0e operations and re=uests to the S9A or .9A /his includes3 for e2ample3 reading data $loc(s

6 % *ogical Data$ase Structures

4or the architecture of an Oracle data$ase we distinguish $etween logical and physical data$ase structures that ma(e up a data$ase *ogical structures descri$e logical areas of storage (name spaces" where o$,ects such as ta$les can $e stored .hysical structures3 in contrast3 are determined $y the operating system files that constitute the data$ase /he logical data$ase structures include5 Data$ase A data$ase consists of one or more storage di0isions3 so1called ta$lespaces /a$lespaces A ta$lespace is a logical di0ision of a data$ase All data$ase o$,ects are logically stored in ta$lespaces 7ach data$ase has at least one ta$lespace3 the SDS/7M ta$lespace3 that contains the data dictionary Other ta$lespaces can $e created and used for different applications or tas(s 6E Segments If a data$ase o$,ect (e g 3 a ta$le or a cluster" is created3 automatically a portion

of the ta$lespace is allocated /his portion is called a segment 4or each ta$le there is a ta$le segment 4or inde2es so1called inde2 segments are allocated /he segment associated with a data$ase o$,ect $elongs to e2actly one ta$lespace 72tent An e2tent is the smallest logical storage unit that can $e allocated for a data$ase o$,ect3 and it consists a contiguous se=uence of data $loc(sF If the si<e of a data$ase o$,ect increases (e g 3 due to insertions of tuples into a ta$le"3 an additional e2tent is allocated for the o$,ect Information a$out the e2tents allocated for data$ase o$,ects can $e found in the data dictionary 0iew ;S7: 7!/7>/S A special type of segments are roll$ac( segments /hey don8t contain a data$ase o$,ect3 $ut contain a G$efore imageH of modified data for which the modifying transaction has not yet $een committed Modifications are undone using roll$ac( segments Oracle uses roll$ac( segments in order to maintain read consistency among multiple users 4urthermore3 roll$ac( segments are used to restore the G$efore imageH of modified tuples in the e0ent of a roll$ac( of the modifying transaction /ypically3 an e2tra ta$lespace (:BS" is used to store roll$ac( segments /his ta$lespace can $e defined during the creation of a data$ase /he si<e of this ta$lespace and its segments depends on the type and si<e of transactions that are typically performed $y application programs A data$ase typically consists of a SDS/7M ta$lespace containing the data dictionary and further internal ta$les3 procedures etc 3 and a ta$lespace for roll$ac( segments Additional ta$lespaces include a ta$lespace for user data (;S7:S"3 a ta$lespace for temporary =uery results and ta$les (/7M."3 and a ta$lespace used $y applications such as S)*C4orms (/OO*S"

6 & .hysical Data$ase Structure

/he physical data$ase structure of an Oracle data$ase is determined $y files and data $loc(s5 Data 4iles A ta$lespace consists of one or more operating system files that are stored on dis( /hus a data$ase essentially is a collection of data files that can $e stored on different storage de0ices (magnetic tape3 optical dis(s etc " /ypically3 only magnetic dis(s are used Multiple data files for a ta$lespace allows the ser0er to distri$ute a data$ase o$,ect o0er multiple dis(s (depending on the si<e of the o$,ect" Bloc(s An e2tent consists of one or more contiguous Oracle data $loc(s A $loc( determines the finest le0el of granularity of where data can $e stored One data $loc( corresponds to a specific num$er of $ytes of physical data$ase space on dis( A data $loc( si<e is specified for each Oracle data$ase when the data$ase is created A data$ase uses and allocates free data$ase space in Oracle data $loc(s Information a$out data $loc(s can $e retrie0ed from the data dictionary 0iews ;S7: S79M7>/S and ;S7: 7!/7>/S /hese 0iews show how many $loc(s are allocated for a data$ase o$,ect and how many $loc(s are a0aila$le (free" in a segment@e2tent 6#

As mentioned in Section 6 #3 aside from datafiles three further types of files are associated with a data$ase instance5 :edo1*og 4iles 7ach data$ase instance maintains a set of redo1log files /hese files are used to record logs of all transactions /he logs are used to reco0er the data$ase8s transactions in their proper order in the e0ent of a data$ase crash (the reco0ering operations are called roll forward" 'hen a transaction is e2ecuted3 modifications are entered in the redo1log $uffer3 while the $loc(s affected $y the transactions are not immediately written $ac( to dis(3 thus allowing optimi<ing the performance through $atch writes Aontrol 4iles 7ach data$ase instance has at least one control file In this file the name of the data$ase instance and the locations (dis(s" of the data files and redo1log files are recorded 7ach time an instance is started3 the data and redo1log files are determined $y using the control file(s" Archi0e@Bac(up 4iles If an instance is running in the archi0e1log mode3 the A:AB process archi0es the modifications of the redo1log files in e2tra archi0e or $ac(up files In contrast to redo1log files3 these files are typically not o0erwritten /he following 7: schema illustrates the architecture of an Oracle data$ase instance and the relationships $etween physical and logical data$ase structures (relationships can $e read as Gconsists ofH"
bloc& tables,ace e-tent segment redo-log file datafile database control file table indecluster rollbac& seg.

4igure -5 :elationships $etween logical and physical data$ase structures 6%

6 + Steps in .rocessing an S)* Statement

In the following we s(etch how an S)* statement is processed $y the Oracle ser0er and which processes and $uffers in0ol0ed # Assume a user (wor(ing with S)*C.lus" issues an update statement on the ta$le /AB such that more than one tuple is affected $y the update /he statement is passed to the ser0er $y the ;S7: process /hen the ser0er (or rather the =uery processor" chec(s whether this statement is already contained in the li$rary cache such that the corresponding information (parse tree3 e2ecution plan" can $e used If the statement can not $e found3 it is parsed and after 0erifying the statement (user pri0ileges3 affected ta$les and columns"

using data from the dictionary cache3 a =uery e2ecution plan is generated $y the =uery optimi<er /ogether with the parse tree3 this plan is stored in the li$rary cache % 4or the o$,ects affected $y the statement (here the ta$le /AB" it is chec(ed3 whether the corresponding data $loc(s already e2ist in the data$ase $uffer If not3 the ;S7: process reads the data $loc(s into the data$ase $uffer If there is not enough space in the $uffer3 the least recently used $loc(s of other o$,ects are written $ac( to the dis( $y the DB': process & /he modifications of the tuples affected $y the update occurs in the data$ase $uffer Before the data $loc(s are modified3 the G$efore imageH of the tuples is written to the roll$ac( segments $y the DB': process + 'hile the redo1log $uffer is filled during the data $loc( modifications3 the *9': process writes entries from the redo1log $uffer to the redo1log files - After all tuples (or rather the corresponding data $loc(s" ha0e $een modified in the data$ase $uffer3 the modifications can $e committed $y the user using the commit command 6 As long as no commit has $een issued $y the user3 modifications can $e undone using the roll$ac( statement In this case3 the modified data $loc(s in the data$ase $uffer are o0erwritten $y the original $loc(s stored in the roll$ac( segments 7 If the user issues a commit3 the space allocated for the $loc(s in the roll$ac( segments is deallocated and can $e used $y other transactions 4urthermore3 the modified $loc(s in the data$ase $uffer are unloc(ed such that other users now can read the modified $loc(s /he end of the transaction (more precisely the commit" is recorded in the redo1log files /he modified $loc(s are only written to the dis( $y the DB': process if the space allocated for the $loc(s is needed for other $loc(s

6 - Areating Data$ase O$,ects

4or data$ase o$,ects (ta$les3 inde2es3 clusters" that re=uire their own storage area3 a segment in a ta$lespace is allocated Since the system typically does not (now what the si<e of the 6& data$ase o$,ect will $e3 some default storage parameters are used /he user3 howe0er3 has the possi$ility to e2plicitly specify the storage parameters using a storage clause in3 e g 3 the create ta$le statement /his specification then o0erwrites the system parameters and allows the user to specify the (e2pected" storage si<e of the o$,ect in terms of e2tents Suppose the following ta$le definition that includes a storage clause5 create ta$le S/OAIS (I/7M 0archar%(&E"3 );A>/I/D num$er(+"" storage (initial #M ne2t +EE( mine2tents # ma2e2tents %E pctincrease -E"J initial and ne2t specify the si<e of the first and ne2t e2tents3 respecti0ely In the definition

a$o0e3 the initial e2tent has a si<e of #MB3 and the ne2t e2tent has a si<e of +EEIB /he parameter mine2tents specifies the total num$er of e2tents allocated when the segment is created /his parameter allows the user to allocate a large amount of space when an o$,ect is created3 e0en if the space a0aila$le is not contiguous /he default and minimum 0alue is # /he parameter ma2e2tents specifies the admissi$le num$er of e2tents /he parameter pctincrease specifies the percent $y which each e2tent after the second grows o0er the pre0ious e2tent /he default 0alue is -E3 meaning that each su$se=uent e2tent is -EK larger than the preceding e2tent Based on the a$o0e ta$le definition3 we thus would get the following logical data$ase structure for the ta$le S/OAIS (assuming that four e2tents ha0e already $een allocated"5
initial (# /00& 100& 200&
(. 3-tent ). 3-tent *. 3-tent /. 3-tent

4igure 65 *ogical Storage Structure of the /a$le S/OAIS If the space re=uired for a data$ase o$,ect is (nown $efore creation3 already the initial e2tent should $e $ig enough to hold the data$ase o$,ect In this case3 the Oracle ser0er (more precisely the resource manager" tries to allocate contiguous data $loc(s on dis(s for this o$,ect3 thus the defragmentation of data $loc(s associated with a data$ase o$,ect can $e pre0ented 4or inde2es a storage clause can $e specified as well create inde2 S/OAI ID! on S/OAIS(I/7M" storage (initial %EE( ne2t #EE( mine2tents # ma2e2tents -"J 6+

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