3. LOG1A LOG1B
LOG2A
/u08
LOG2B
/u09 CNTRL2
/u04
CNTRL1
/u06 /u07 /u03
$ORACLE_
HOME/dbs
initSID.ora
DATA
/u01
INDX
/u02
SYSTEM
RBS
/u04
TEMP
/u05
/u03
Oracle Architecture Overview
PMON
SMON
RECO
SNPnn LCnn
Pnn
Snn
Dnn
Archived
Redo
Logs
DBWR CKPT LGWR ARCH
Server Process
User Process
PGA
L
R
U
Dirty
System Global Area
Database Buffer Cache
Redo Log
Buffer
Dictionary
Cache
Library
Cache
Shared Pool Area
/u10
4. BLOCK
1. Unit of storage
2. In multiples of OS block
3. Data, e.g. in Tables is stored in
a Block
4. Smallest unit of I /O
A Contiguous section of Blocks
forms an EXTENT
Header :Block Address, type of segment
Table Directory : Information about
tables having rows in this Block
Row Directory : Information about rows
Row Data
Free space : For inserting new rows &
updating existing rows. This is controlled
by PCTFREE & PCTUSED parameters
Transaction entries
Data Block Format
5. Table, Index, cluster or
Other segments
Data File
Data File
Extents
Extents
SEGMENT
Extents are allotted
To Segments
Extents can be allocated to Segments from multiple data files
Extents can not span data files
Segments can span data files & hence even different disks
7. Tablespaces & Segments
Segments
• A Segment can span datafiles of one
tablespace
• A Segment occupies only one tablespace
• You can not control placement of extents
of a segment in datafiles.
• You segregate your objects (segments)
by keeping them in separate tablespaces.
• One tablespace can contain objects of
different schemas. I.e.. a tablespace is not
owned by a user.
s
emp
D A T A B A S E
dept
T A B L E S PA C E
ScottSchema
Ram
System Tablespace :
• Created by Oracle when database is
created.
• Contains Data Dictionary & Pl/SQL
units.
• User objects must be kept separate
• Users can be allotted quota on tablespaces.
• There is a default tablespace for a user in which his objects are created.
• Space utilization can be controlled by storage properties of TS & segments.
• Segregation of objects, applications can be controlled. Tablespaces can be taken
offline.
Criteria's for different Tablespaces : Growing/ Constant , Extents proportions
•Active/Inactive, Belonging to different apps, system/ temp/ user/index, to avoid
8. About Blocks,extents,segments & Tablespaces
• Data Block is the smallest unit of I/O.
• Segment represents objects in the Database such as
Tables,indexes,clusters as well as other structures such as
Rollback segments
• Physical storage in Datafiles is logically represented by
tablespace. User creates objects in tablespace. E. g.
• A segment is allotted space in only one Tablespace in
which it is created. Tablespace can contain multiple
segments.
• The size of a Tablespace is the size of the Datafiles
constituting the Tablespace.
• The size of database is the total size of Tablespaces
costituting the database.
9. Segments
Data Segments :These are created
in a particular tablespace with
the Create command.
• Storage parameters determine
how extents are allocated or
defaults of the tablespace are
used.
Index Segments : Every Index has a single
Index segment. Index segment with storage
parameters can be created with Create Index
command.
• Temporary segments : Oracle automatically
creates for intermediate & sorting operations.
It is created in the default Temporary
tablespace of the User. Oracle drops Temp.
segment, when statement completes.Rollback Segments :
Rollback Segments are used : To provide read consistency, To Rollback
transactions & to recover the database.
• Oracle automatically assigns rollback segments OR a transaction can use a
specific rollback segment.
• When a transaction is committed, rollback information is released, but not
destroyed immediately -- for creating read consistent views of data.
• A transaction writes to one extent at a time. When it is full, it can reuse existing
extent OR acquire a new extent -- this depends upon active extent and Maxextents
parameter.
• Rollback segment SYSTEM is created by Oracle when database is created. It is
in the System Tablespace. You should create additional Rollback segments.
10. Rollback Segments
Undo Information :
Block identification &
before image
Rollback Segment
The change here generates Redo log. The Rollback
segment data is restored & used after system crash
Changes of one transaction are chained in entries of a transaction table
Applied change
Select --( SCN=7920)-
7900
7902
7930
7900
7940
7910
7912
7915
Rollback
Segments
Transactions &
Read Consistency
Oracle uses rollback
entries in the Rollback
segments to create read
consistent results for
queries
If E3 is not active, it can be used.
Similarly when E1 is available it will be
used. Otherwise a new extent will be
added.
11. Memory required by Oracle
• Data Dictionary
• User Data
• SQL queries
• PL/SQL Blocks
• Rollback ( Undo) data
• REDO data
• Temporary data
FILE - I/O
Should be
minimum
USERS
Generate REDO
for Back-up
Generate Undo Information
for rollback and data
consistence during
transactions
12. Memory Structures Of Oracle
SHARED POOL
Dictionary
Cash
SQL
PL/SQL
Control
Structures
Control
Structures
DataBase
Buffer
Cache
REDO
LOG
BUFFER
Library Cache
13. Oracle Processes
Server Process :
• Parses & executes SQL statements.
• Reads data blocks from disk to Database Buffer
cache.
• Return the results of SQL statements to the User
Process.
PMON : Process Monitor
• Cleans abnormally terminated user sessions.
• Rolls back uncommitted transactions, releases
locks and frees SGA resources allotted to the user
process
SMON : System Monitor
• Performs automatic instance recovery.
• Reclaims space used by temporary segments
• Merges contiguous areas of free space in data files
( Coalescing or Defragging)
CKPT : Checkpoint
Process
• Updates file headers of
Control files & data files at
Checkpoint
D B W R : Database
Writer process
L G W R : Log writer
process
Dispatcher Process
RECO process
A R C H : Archiver
Process
14. Processes
Client Application Oracle Server
Single Task Oracle
Client
Application
NET 8
Server
Process
S G A
Client
Application
Server
Process
Dedicated Server
Listener
18. Database Buffer Cache & DBWR
LRU End MRU End
Dirty List
Dirty Buffer
User
Process
Cache Hit
Cache Miss
DBWR SQL Query
DBWR writes dirty buffers to disk when -
Dirty Buffers reach a threshold value
No free blocks are available in LRU list
after server process scans sp. buffers
A timeout occurs : 3 secs
A DBWR checkpoint takes place
Database
Buffer
Cache
Age
19. REDO -- SETUP
Buffer Cache
ON - LINE Re
Do Log Files
Data Files
Archive Logs
USER
USER LGWR
Archiver
Log
Buffer
DBWR
LGWR : Writes Redo in Log Buffer to On Line Redo
Log Files When
The redo log buffer is 1/3 full
A timeout occurs (about every 3 seconds)
Before DBWR writes modified blocks to the data
files
A transaction COMMITS
20. Shared Pool
Shared SQLArea
Parsed SQL Statement
Parsed SQL Statement
Parsed SQL Statement
Server1
Server n
Shared PL/SQLArea
Parsed/compiled PL/ SQL
Statement
Parsed/compiled PL/ SQL
StatementP G A
P G A
Program Global Area : Contains values specific to the sessions I.e. local, global or packaged
variables. Bind information in case of SQL statements. In MTS configuration user session info.
Is kept in the shared pool.
Dictionary Cache : Data Dictionary information is cached here for the user processes.
A Shared SQL area remains there until it is flushed out by LRU type mechanism
Dictionary cache
S G A size is determined by :
DB_BLOCK_SIZE : Size of a single data block DB_BLOCK_BFFERS : Number of
buffers in D.B. Buffer cache LOG_BUFFER : Size in bytes of Redo Log Buffers
SHARED_POOL_SIZE : Size in bytes of the shared pool
All the above are configured in the parameter file.
21. Processing SQL Statements
Parsing : SQL
User Process
SQL
Server Process
Shared
Pool
Check for
Syntax
Check for
Table / Column
definitions
Check for
Privileges
Prepare
Execution Plan
Load in
Shared Pool
Executing :
P G A
Parsed code
executed
Applied to
data buffers
Perform physical
reads
Perform constraint
checking
For Select or Query Read the block if already
in D.B. Buffer cache
Perform a physical read if
Block is not in memory
For DML
Statements :
Acquire data & rollback blocks
into D.B. buffer cache
Place exclusive row locks
on the rows about to change
Save rollback data into
rollback segment block buffer
Store change-records to
Redo Log buffer
Apply changes
to the Block
22. Oracle Database Files
Data Files :
• Store Data Dictionary, User
Objects, Data for Undoing
Transactions(Rollback)
Redo Log Files :
• Record changes made to Database
for using them in Recovery.
• There must be at least two Redo Log
groups . The groups are written in
circular fashion.
• Each Redo Log group must contain
same number of members.
Control Files :
A binary file that describes the
structure of the database.
Required to mount, open, and
access the database.
Synchronization info needed
for recovery is stored in the
control file
Recommended configuration is
a min of two control files on
separate disks.
Parameter File :
Used to size the SGA and
locate the control files at
instance start up.
Contains all the database
initialization parameters.
Archieved Redo Log File :
Offline storage of Redo Logs for
complete Database Recovery
Trace File :Contain internal errors
Alert Files : Logs deadlock, Startup /
Shutdowns , Initialization parameters at
instance startup.
24. Oracle Startup
NOMOUNT
•Read Init.ora
• Identify Control File
• Create & Initialize SGA
• Start Background Processes
MOUNT
• Open Control Files
• Get Instance lock on Database
OPEN
• Open & lock datafiles
• Open On - Line Redo Log
• Perform Crash Recovery
Startup
Nomount
Startup Mount
Startup Open
Instance Started
Database Mounted
Database Opened
25. Oracle Database Shutdown
Stop access to database
Wait until Users Exit
Flush Redo logs & Database
buffer caches.
Drop File locks
Complete ongoing transactions
Cancel Active
Transactions & Rollback
Update File Headers
Synchronize Control files & D B files
Shutdown Immediate
Shutdown Normal
Shutdown Abort