Saturday, July 31, 2010

Oracle Database Basic Architecture

                                                                                                                                         -Srikanth Pulicherla
Basically, there are two main components of Oracle database, instance and database itself. An instance consists of some memory structures and the background processes, whereas a database refers to the disk resources. 




Instance
The memory structures and background processes constitute an instance. The memory structures are System Global Area (SGA), Program Global Area (PGA), and an optional area Software Area Code. In the other hand, the mandatory background processes are Database Writer (DBWn), Log Writer (LGWR), Checkpoint (CKPT), System Monitor (SMON), and Process Monitor (PMON).And another optional background processes are Archive (ARCn), Recovery (RECO),etc.


System Global Area
SGA is the primary memory structure. SGA comprises of Buffer Cache, Shared Pool, Redo Log Buffer, Large Pool, and Java Pool.

Buffer Cache
Buffer cache is used to stores the copies of data block that retrieved from datafiles. That is, when user retrieves data from database, the data will be stored in buffer cache. Its size can be manipulated via DB_CACHE_SIZE parameter in init.ora initialization parameter file.

Shared Pool
Shared pool is broken into library Cache and dictionary Cache. The library cache is used to stores information about the commonly used SQL and PL/SQL statements, and is managed by a Least Recently Used (LRU) algorithm. It is also enables the sharing those statements among users. In the other hand, dictionary cache is used to stores information about object definitions in the database, such as columns, tables, indexes, users, privileges, etc.

The shared pool size can be set via SHARED_POOL_SIZE parameter in init.ora initialization parameter file.

Redo Log Buffer
Each DML statement (insert, update, and delete) executed by users will generates the redo entry. What is a redo entry? It is information about all data changes made by users. That redo entry is stored in redo log buffer before it is written into the redo log files. To manipulate the size of redo log buffer, you can use the LOG_BUFFER parameter in init.ora initialization parameter file.

Large Pool
Large pool is an optional area of memory in the SGA. It is used to relieve the burden place on the shared pool. It is also used for I/O processes. The large pool size can be set by LARGE_POOL_SIZE parameter in init.ora initialization parameter file.

Java Pool

As its name, Java pool is used to services parsing of the Java commands. Its size can be set by JAVA_POOL_SIZE parameter in init.ora initialization parameter file.

Program Global Area
Although the result of SQL statement parsing is stored in library cache, the value of binding variable will be stored in PGA.Because it must be private or not shared among users. The PGA is also used for sort area.

Software Area Code
Software area code is a location in memory where the Oracle application software resides.

Oracle Background Processes
Oracle background processes is the processes behind the scene that work together with the memories.




DBWn
Database writer (DBWn) process is used to write data from buffer cache into the datafiles. Historically, the database writer is named DBWR. But since some of Oracle version allows us to have more than one database writer, the name is changed to DBWn, where n value is a number 0 to 9.

LGWR
Log writer (LGWR) process is similar to DBWn. It writes the redo entries from redo log buffer into the redo log files.

CKPT
Checkpoint (CKPT) is a process to trigger DBWn to writes data in the buffer cache into datafiles. It will also updates datafiles and control files header when log file switch occurs.

SMON
System Monitor (SMON) process is used to recover the system crash or instance failure by applying the entries in the redo log files to the datafiles.

PMON
Process Monitor (PMON) process is used to clean up work after failed processes by rolling back the transactions and releasing other resources.

Database
The database refers to disk resources, and is broken into two main structures, logical structures and physical structures.

Logical Structures
Oracle database is divided into smaller logical units to manage, store, and retrieve data efficiently. The logical units are tablespace, segment, extent, and data block.

Tablespace
A Tablespace is a logical storage unit. Every oracle database contains SYSTEM and SYSAUX tablespaces by default when database is created. These two are system tablespaces. Extra tablespaces will be tablespaces will be created for user data. Tablespace is composed by one or more datafiles.

Segment
A Tablespace is further broken into segments. A segment is used to stores same type of objects. That is, every table in the database will store into a specific segment (named Data Segment) and every index in the database will also store in its own segment (named Index Segment). The other segment types are Temporary Segment and Rollback Segment.

Extent
A segment is further broken into extents. An extent consists of one or more data block. When the database object is enlarged, an extent will be allocated. Unlike a tablespace or a segment, an extent cannot be named.

Data Block
A data block is the smallest unit of storage in the Oracle database. The data block size is a specific number of bytes within tablespace and it has the same number of bytes. Standard data block size is specified by DB_BLOCK_SIZE initialization parameter.


 
Physical Structures
The physical structures are structures of an Oracle database (in this case the disk files) that are not directly manipulated by users. The physical structure consists of datafiles, redo log files, control files, archive log files, parameter files, alert and trace log files and backup files.

Datafiles
Oracle database consists of one or more physical datafiles. Datafiles contains actual database data or logical structures such as tables, indexes.

Redo Log Files
Redo log files are the files that store the redo entries generated by DML statements. It can be used for recovery processes.

Control Files
Control files are used to store information about physical structure of database, such as datafiles size and location, redo log files location


 

No comments:

Post a Comment