8/9/2019 1 Database Architecture
1/53
Oracle Database Architecture
Prepared ByProduct Alliance Group
Tata Consultancy Services
Ahmedabad
8/9/2019 1 Database Architecture
2/53
ArchitecturePhysical Structure
Logical Structure
8/9/2019 1 Database Architecture
3/53
ArchitectureInstance
SGA
Redo log
buffer cache
Shared pool
Data Dict.
cache
Library
cache
DBWRSMONPMON CKPTLGWR Others
User
process
Server
processPGA
Controlfiles
Datafiles Archived
log files
Parameter
file
Password
file
Redo logfiles
Database
buffer cache
8/9/2019 1 Database Architecture
4/53
Physical StructuresData-files
Control Files
Redo Log Files
Archive Log Files
Parameter Files
Alert and Trace Log Files
Backup Files
8/9/2019 1 Database Architecture
5/53
DatafilesContain all the database data.
Data of logical database structures, such as tables
and indexes, is physically stored in the datafilesallocated for a database.
A data-file can be associated with only onedatabase.
Can automatically extend when the database runs
out of space.One or more datafiles form a logical unit of
database storage called a tablespace.
8/9/2019 1 Database Architecture
6/53
Control Files Specify the physical structure of the database.
Database name
Names and locations of datafiles and redo log files
Time stamp of database creation Multiplex the control file to protect against a failure
involving the control file.
When an instance of an Oracle database is started, itscontrol file identifies the database and redo log files thatmust be opened for database operation to proceed.
When physical makeup of the database is altered, controlfile is automatically modified by Oracle to reflect thechange.
Used in database recovery.
8/9/2019 1 Database Architecture
7/53
Redo Log Files Every Oracle database has a set of two or more redo log
files.
Record all changes made to data.
Multiplexed redo log so that two or more copies of theredo log can be maintained on different disks.
The information in a redo log file is used only to recoverthe database from a system or media failure that preventsdatabase data from being written to the datafiles.
The process of applying the redo log during a recoveryoperation is called rolling forward.
8/9/2019 1 Database Architecture
8/53
Parameter FilesParameter files contain a list of configuration
parameters for that instance and database.
Oracle recommends that you create a serverparameter file (SPFILE) as a dynamic means of
maintaining initialization parameters.
A server parameter file lets you store and manage
your initialization parameters persistently in aserver-side disk file.
8/9/2019 1 Database Architecture
9/53
Alert and Trace Log Files Each server and background process can write to an
associated trace file.
When an internal error is detected by a process, it dumps
information about the error to its trace file. Some of the information written to a trace file is intended
for the database administrator, while other information isfor Oracle Support Services.
Trace file information is also used to tune applications and
instances. The alert file, or alert log, is a special trace file. The alert
log of a database is a chronological log of messages anderrors.
8/9/2019 1 Database Architecture
10/53
Logical StructuresTablespaces
Oracle Data Blocks
Extents
Segments
8/9/2019 1 Database Architecture
11/53
Tablespaces
Groups related logical structures together.
One or more datafiles are explicitly created for eachtablespace to physically store the data of all logicalstructures in a tablespace.
Every database contains a SYSTEM and a SYSAUX (indatabase 10g Only).
The default is a smallfile tablespace, which is thetraditional type of Oracle tablespace.
The SYSTEM and SYSAUX tablespaces are created assmallfile tablespaces.
Bigfile tablespaces contain tablespaces made up of singlelarge files rather than numerous smaller ones.
With Bigfile tablespaces database can scale up to 8exabytes in size.
8/9/2019 1 Database Architecture
12/53
Oracle Data BlocksAt the finest level of granularity, data is stored in
data blocks.
One data block corresponds to a specific numberof bytes of physical database space on disk.
The standard block size is specified by theDB_BLOCK_SIZE initialization parameter.
In addition, you can specify up to five other block
sizes. A database uses and allocates free database space
in Oracle data blocks.
8/9/2019 1 Database Architecture
13/53
Extents
The next level of logical database space is
an extent.
An extent is a specific number of
contiguous data blocks, obtained in a single
allocation, used to store a specific type of
information.
8/9/2019 1 Database Architecture
14/53
Segments
Above extents, the level of logical database
storage is a segment.
A segment is a set of extents allocated for a certainlogical structure. The following table describes the
different types of segments.
Data segment
Index segment
Temporary segment
Rollback segment
8/9/2019 1 Database Architecture
15/53
Graphically
8/9/2019 1 Database Architecture
16/53
Database
Logical Physical
Tablespace Data file
OS blockOracle
block
Segment
Extent
Database Storage Hierarchy
8/9/2019 1 Database Architecture
17/53
Overview of Schemas and Common
Schema Objects
Tables
Indexes
Views
Clusters
Synonyms
8/9/2019 1 Database Architecture
18/53
Tables
Tables are the basic unit of data storage in
an Oracle database.
Each table has column and row.A table that has an employee database, for
example, can have a column called
employee number, and each row in thatcolumn is an employee's number.
8/9/2019 1 Database Architecture
19/53
Indexes
Optional structures associated with tables.
Can be created to increase the performance of dataretrieval.
When processing a request, Oracle can use some or all ofthe available indexes to locate the requested rowsefficiently.
Useful when applications frequently query a table for arange of rows
Indexes are created on one or more columns of a table.
After it is created, it is automatically maintained and usedby Oracle.
Changes to table data (such as adding new rows, updatingrows, or deleting rows) are automatically incorporated intoall relevant indexes.
8/9/2019 1 Database Architecture
20/53
Views Customized presentations of data in one or more tables or
other views.
Can also be considered a stored query.
Do not actually contain data.
They derive their data from the base tables on which theyare based.
Can be queried, updated, inserted into, and deleted from,with some restrictions.
All operations performed on a view actually affect the basetables of the view.
Provide an additional level of table security by restrictingaccess to a predetermined set of rows and columns of atable.
Hide data complexity and store complex queries.
8/9/2019 1 Database Architecture
21/53
ClustersClusters are groups of one or more tables
physically stored together because they sharecommon columns and are often used together.
Because related rows are physically storedtogether, disk access time improves.
Do not affect application design.
Whether a table is part of a cluster is transparent to
users and to applications.Data stored in a clustered table is accessed by
SQL in the same way as data stored in a nonclustered table.
8/9/2019 1 Database Architecture
22/53
Synonyms
A synonym is an alias for any table, view,
materialized view, sequence, procedure,
function, package, type, Java class schemaobject, user-defined object type, or another
synonym.
Because a synonym is simply an alias, it
requires no storage other than its definition
in the data dictionary.
8/9/2019 1 Database Architecture
23/53
Overview of the Oracle Data
Dictionary It is a set of tables and views that are used as a
read-only reference about the database.
Stores information about both the logical andphysical structure of the database.
A data dictionary also stores
The valid users of an Oracle database
Information about integrity constraints definedfor tables in the database
The amount of space allocated for a schemaobject and how much of it is in use
8/9/2019 1 Database Architecture
24/53
Overview of the Oracle Data
Dictionary
Automatically updated by Oracle when the
structure of the database is altered.
The database relies on the data dictionary to
record, verify, and conduct ongoing work.
8/9/2019 1 Database Architecture
25/53
Overview of the Oracle InstanceThe combination of
Memory buffers
Background processes
8/9/2019 1 Database Architecture
26/53
Instance Memory StructuresSystem Global Area
Database Buffer Cache
Redo Log Buffer
Shared Pool
Large pool
Java pool
Program Global Area
8/9/2019 1 Database Architecture
27/53
System Global Area
Instance
SGA
Redo log
buffer cache
Shared pool
Data Dict.
cache
Library
cache Database
buffer cache
SGA is a shared memory region that contains data andcontrol information for one Oracle instance.
Oracle allocates the SGA when an instance starts and de-
allocates it when the instance shuts down.
Each instance has its own SGA
Users connected to database share the data in the SGA.
8/9/2019 1 Database Architecture
28/53
System Global Area
Database Buffer Cache
The database buffer cache stores copies of datablocks that have been retrieved from the data files.
It enables great performance gains when youobtain and update data.
It is managed through a least recently used (LRU)algorithm.
DB_CACHE_SIZEdetermines thesize of database buffer cache Database buffer
cache
8/9/2019 1 Database Architecture
29/53
System Global Area
Redo Log Buffer
The redo log buffer cache records all changes made to thedatabase data blocks.
Its primary purpose is recovery. Changes recorded within are called redo entries.
Redo entries contain information to reconstruct or redochanges.
Size is defined by LOG_BUFFER.
Redo log
buffer cache
8/9/2019 1 Database Architecture
30/53
System Global Area
Shared Pool Used to store the most recently executed SQL statements
and the most recently used data definitions.
It consists of two key performance-related memorystructures
Library cache
Data dictionary cache
Sized by the parameter SHARED_POOL_SIZE
ALTER SYSTEM SET SHARED_POOL_SIZE = 64M;
Shared pool
Data dictionary
cache
Library
cache
8/9/2019 1 Database Architecture
31/53
System Global AreaLibrary cache The library cache stores information about the most
recently used SQL and PL/SQL statements.
The library cache enables the sharing of commonly usedstatements
Is managed by a least recently used (LRU) algorithm
Consists of two structures:
Shared SQL area
Shared PL/SQL area Has its size determined by the shared pool sizing
8/9/2019 1 Database Architecture
32/53
System Global AreaData dictionary cache
The data dictionary cache is a collection of the mostrecently used definitions in the database.
It includes information about database files, tables,indexes, columns, users, privileges, and other databaseobjects.
During the parse phase, the server process looks at the datadictionary for information to resolve object names and
validate access. Caching the data dictionary information into memory
improves response time on queries.
Size is determined by the shared pool sizing.
8/9/2019 1 Database Architecture
33/53
System Global AreaLarge pool
The large pool is an optional area of memory in the SGAconfigured only in a shared server environment.
It relieves the burden placed on the shared pool.
This configured memory area is used for session memory(UGA), I/O slaves, and backup and restore operations.
Unlike the shared pool, the large pool does not use an LRU
list. Sized by LARGE_POOL_SIZE.
ALTER SYSTEM SET LARGE_POOL_SIZE = 64M;
8/9/2019 1 Database Architecture
34/53
System Global AreaJava pool
The Java pool services the parsing
requirements for Java commands.Required if installing and using Java.
It is stored much the same way as PL/SQL indatabase tables.
It is sized by the JAVA_POOL_SIZEparameter.
8/9/2019 1 Database Architecture
35/53
Program Global Area (PGA)
The PGA is memory reserved for each user process that
connects to an Oracle database.
User
process
Stackspace
Sessioninformation
sort area, cursorinformation
SGA
Shared SQL areas
SGASession
information
PGA Dedicated server Shared server
Serverprocess
Shared SQL areas
Stackspace
sort area, cursorinformation
8/9/2019 1 Database Architecture
36/53
User Process A user process is a program that requests interaction with
the Oracle server.
It must first establish a connection.
It does not interact directly with the Oracle server.
Database user
Serverprocess
Userprocess
Connection
established
8/9/2019 1 Database Architecture
37/53
Server Process
A server process is a program that directly interacts with
the Oracle server. It fulfills calls generated and returns results.
Can be dedicated or shared server.
Connection
establishedSession created
Database user
Userprocess
Oracle server
Serverprocess
8/9/2019 1 Database Architecture
38/53
Oracle Background Processes The relationship between the physical and memory
structures is maintained and enforced by Oraclesbackground processes.
Mandatory background processesDBWn PMON CKPT
LGWR SMON RECO
Optional background processes
ARCn LMON Snnn
QMNn LMDn CJQ0 Pnnn
LCKn Dnnn
8/9/2019 1 Database Architecture
39/53
Instance
SGA
Database
buffercache
DBWn
Controlfiles
Datafiles
Redo logfiles
Database
DBWn writes when:
Checkpoint
Dirty buffers threshold reached
No free buffers
Timeout
RAC ping request
Tablespace offline
Tablespace read only
Table DROP orTRUNCATE
Tablespace BEGIN BACKUP
Database Writer (DBWn)
8/9/2019 1 Database Architecture
40/53
Instance
SGA
DBWn
Redo log
buffer
ControlfilesDatafiles Redo logfiles
LGWR
Database
LGWR writes:
At commit
When one-third full
When there is 1 MB ofredo
Every 3 seconds
Before DBWn writes
Log Writer (LGWR)
8/9/2019 1 Database Architecture
41/53
Instance
SGA
SMON
Control
files
Data
files
Redo log
files
Instance
SGA
SMON
Database
Responsibilities:
Instance recovery:
Rolls forward changes in
the redo logs
Opens the database for
user access Rolls back uncommitted
transactions
Coalesces free space ever 3 sec
Deallocates temporary
segments
System Monitor (SMON)
8/9/2019 1 Database Architecture
42/53
Process Monitor (PMON)
Cleans up after
failed processes by:
Rolling back the transaction
Releasing locks
Releasing other resources
Restarts dead dispatchers
Instance
SGA
PMON
PGA area
8/9/2019 1 Database Architecture
43/53
Instance
SGA
DWW0
Redo Log
Buffer
LGWR
Instance
SGA
DBWn LGWR CKPT
Controlfiles
Datafiles
Redo logfiles
Checkpoint (CKPT)
Responsible for:
Signaling DBWn at
checkpoints
Updating datafileheaders with
checkpoint
information
Updating control files
with checkpoint
information
8/9/2019 1 Database Architecture
44/53
Archiver (ARCn) Optional background process
Automatically archives online redo logs when
ARCHIVELOG mode is set Preserves the record of all changes made to the database
Controlfiles
Datafiles
Redo logfiles
ArchivedRedo log
files
ARCnARCn
8/9/2019 1 Database Architecture
45/53
Starting Up a Database
OPEN
MOUNT
NOMOUNT
SHUTDOWN
All files opened as
described by the control
file for this instance
Control file
opened for this
instance
STARTUP
SHUTDOWN
Instance
started pfile
or spfile used
8/9/2019 1 Database Architecture
46/53
Shutting Down the Database
Shutdown Mode:
NORMAL
TRANSACTIONAL
IMMEDIATE
ABORT
A
x
x
x
x
T
x
x
o
o
I
x
x
x
o
Shutdown Mode
Allow new connections
Wait until current sessions end
Wait until current transactions end
Force a checkpoint and close files
N
x
o
o
o
YESNOx
o
8/9/2019 1 Database Architecture
47/53
Shutdown OptionsDuring a
Shutdown Normal,
Shutdown Transactional
or
Shutdown Immediate
Consistent Database
(clean database)
On the way down:
Database buffer
cache written to
the data files Uncommitted
changes rolled
back
Resources
released.
On the way up:
No instance
recovery
8/9/2019 1 Database Architecture
48/53
Shutdown OptionsDuring a
Shutdown Abort
or
Instance Failure
or
Startup Force
Inconsistent Database
(dirty database)
On the way down:
Modified buffers
are not written to
the data files
Uncommitted
changes are not
rolled back
On the way up:
Redo logs used to
reapply changes
Undo segments
used to roll back
uncommitted
changes
Resources
released
8/9/2019 1 Database Architecture
49/53
How Oracle Works
1. An instance has started on the computer running Oracle
2. A computer running an application (a local computer orclient workstation) runs the application in a user process.
The client application attempts to establish a connection tothe server using the proper Oracle Net Services driver.
3. The server is running the proper Oracle Net Servicesdriver. The server detects the connection request from theapplication and creates a dedicated server process on
behalf of the user process.
4. The user runs a SQL statement and commits thetransaction.
8/9/2019 1 Database Architecture
50/53
How Oracle Works
5. The server process receives the statement and checks theshared pool for any shared SQL area that contains asimilar SQL statement. If a shared SQL area is found, thenthe server process checks the user's access privileges to therequested data, and the previously existing shared SQL
area is used to process the statement. If not, then a newshared SQL area is allocated for the statement, so it can be
parsed and processed.
6. The server process retrieves any necessary data valuesfrom the actual datafile (table) or those stored in the SGA.
7. The server process modifies data in the system global area.The DBWnprocess writes modified blocks permanently todisk when doing so is efficient. Because the transaction iscommitted, the LGWR process immediately records thetransaction in the redo log file.
8/9/2019 1 Database Architecture
51/53
How Oracle Works
8. If the transaction is successful, then the serverprocess sends a message across the network tothe application. If it is not successful, then anerror message is transmitted.
9. Throughout this entire procedure, the otherbackground processes run, watching forconditions that require intervention. In addition,the database server manages other users'transactions and prevents contention betweentransactions that request the same data.
8/9/2019 1 Database Architecture
52/53
Q & A
8/9/2019 1 Database Architecture
53/53
Thank You