If you are having trouble getting your head around the basics of Oracles Architecture, this video does a good job of simplifying things and making it easy to remember by breaking it down and describing it via everyday examples. You can skip to around 2:30 for the real start of the video.
Datafiles – on disk
read to memory
data – buffer cache
sql goes to shared pool – library cache
executed sql goes to redo log buffer
Operations on the data always happen in memory. (database buffer)
Queries gets stored in the shared library
Subsequent queries (repeats) can be retrieved directly from the shared library and the buffer cache.
On entering data, process has to wait until data is written to datafile. This is inefficient as writing data out is slow.
Faster way is to use a scrap of paper to quickly jot it down then when have time write it to the ledger
So data goes to memory then the redo buffer then on a checkpoint, gets written to disk.
Once it is in the redo log, it is considered finished.
Before modifying data, the old values are recorded in the rollback segment
When a transaction is canceled, it is rolled back by retrieving the old values from the rollback segment and putting them back.
[embedplusvideo height=”356″ width=”584″ standard=”http://www.youtube.com/v/L_2TfSHotsY?fs=1″ vars=”ytid=L_2TfSHotsY&width=584&height=356&start=&stop=&rs=w&hd=0&autoplay=0&react=1&chapters=¬es=” id=”ep6822″ /]
Watch the rest of this series:
Initilisation params for the Buffer cache:
- It is very helpfull if the buffer block size is a multiple of your operating system block size.
The Buffer cache is controled with a Least Recently Used (LRU) algorithm which determines what stays in and what gets removed from the SGA.
The goal being to have the data that is accesses most frequently kept in the SGA so that it can be accessed fast.
The purpose of the Shared pool is to reduce parsing
The Shared pool consists of 2 parts:
- Library Cache
- text of sql statements
- meta code – compiled version of above text
- execution plan that the optimiser will use
- Dictionary Cache
- names of objects that have been touched recently
- privalages and roles – access information
The Shared Pool also usesa LRU algorithm.
Initialization parameter – shared_pool_size controls size of shared pool.
- Initilization parameter – java_pool_size
- large pool – optional
- if using RMAN configure a large large pool
- shared server uses this
Watch Part 4
[embedplusvideo height=”328″ width=”584″ standard=”http://www.youtube.com/v/wmc9uxNW99E?fs=1″ vars=”ytid=wmc9uxNW99E&width=584&height=328&start=&stop=&rs=w&hd=0&autoplay=0&react=1&chapters=¬es=” id=”ep5503″ /]
Check out part 1 first.
Online Redo Logs
- Contains Redo and Undo info
- DDL – Create alter drop
- Need at least 2 files/groups
- Should be multiplexed each on different devices and controlers
- When each file fils, next one is started and old one is archived (if in Archivelogmode)
An Oracle database is comprised of datafiles, control files
and redo logs.
The second part is the memory – the SGA (system global area
or shared global memory)
Database Buffer Cache
Comprised of Oracle data blocks
There are 4 main types of data blocks, which are the same as the 4 types of data mentioned earlier:
The Users server process is the process that handles the users requests to the oracle database.
When the user requests a add, update or delete of data in the database, the server process modifies the data from the buffer cache, not the actual data files.
The DBWR (Database Writer) process is the only process that writes to the data files.
Here is the process by which data is modified in the Oracle database:
If the operation is an Insert:
Space found in a block in buffer cache.
Data inserted into that block buffer.
If the operation is an Update or a Delete:
The data is read, either from the buffer cache or the data files and if from the datafiles, it is placed in the buffer.
The data is deleted or modified in the buffer cache.
A copy of the origional data written to the UNDO tablespace in case it is needed for a rollback or for read consistency.
Once the data is modified in the Buffer Cache, a log file is written to the Redo log.
Once the Redo log is written out, the change is considered complete.
Later…the DBWR writes the changed blocks to the datafiles.
The DBWR is the only process that can write to datafiles but the Server Processes can read form them.
Reading from the Oracle RDMS is done by the users server process
Once a query is submitted, the users server process first determines if data is in the buffer cache of the SGA (System Global Area) memory area.
If the data is not already in the buffer cache, Oracle reads the data from the data files on the disk and writes it to the SGA.
The data is returned to the user or manipulated in memory from there, not from disk.
This means that commonly used data can be accessed form the Buffer Cache which is in RAM and very fast and not form the disk which is slow.
This is a very scalable architecture.