Memory Structure of Oracle
Oracle Server
Oracle Server is the combination of Oracle Instance and Oracle Database. Oracle Instance is consist of SGA (Shared Global Area) and some Background processes. Oracle Database consist of three file types, Data files, Control files, and Redo log files.
Oracle Server
Oracle Database
Oracle Instance
Connection Processes
During connection to Oracle Server using SQL *Plus, Developer, Report, etc, a User Process is created.
User Process then connect to the Server Process. The Server Process check the user privileges and then connect to the Oracle Server. Note: The User Process cannot directly interact with Oracle Server.
Server Process
Oracle Server
User Process
Memory Structure and Processes
DBWR: Database writer is use to write blocks in data files from Database Buffer Cache.
Instance
Shared Pool
Library Cache Database Data Dict Buffer Cache Redo log Buffer Cache
LGWR: Log writer writes blocks in the Redo log files from Redo log Buffer Cache.
PMON: Process Monitor cleans up after failed processes.
SGA
SMON: System Monitor is use for Instance recovery.
CKPT: Check point is just like a buzzer, Check point force DBWR and LGWR to write the data from caches to files.
Cache
PMON
SMON
CKPT
DBWR
LGWR
Data Files
Undo Segment
Control Files
Redo log Files
Database
Shared Pool
1. Library Cache stores information about the most recently used SQL and PL/SQL statements.
Instance
Shared Pool
Library
SGA
2. Data Dictionary Cache is a collection of the most recent used definition in the database.
Cache
Data Dict Cache
Data Files
Control Files
Redo log Files
Database
Database Buffer Cache
Database Buffer Cache stores the copy of the tables which are query by a statement.
Instance SGA
Database Buffer Cache
DBWR process writes the modified records in the Data files from Database Buffer Cache. Check point is just like a buzzer, Check point force DBWR to write the data from cache to files.
CKPT
DBWR
Data Files
Database
Redo Log Buffer Cache
The Redo Log Buffer Cache records all changes made to the Database Buffer Cache. The main purpose of Redo Log Buffer is Recovery LGWR process writes the records in the Redo log files from Redo Log Buffer Cache after every Commit, 3 seconds
Database Buffer Cache
Instance SGA
Redo log Buffer Cache
LGWR
Undo Segment stores changed records. After ROLLBACK, the previous data come from undo segment to the Database buffer cache.
Data Files
Undo Segment
Redo log Files
Database
Process behind SQL statement
Instance
Server Process Shared Pool
Library Cache Database Redo log Buffer Cache
SGA
User Process
Data Dict
Buffer Cache
Cache
PMON
SMON
CKPT
DBWR
LGWR
Select * from emp;
Prepare Execution plan. In fetchstatement syntax. Check statement syntax. Check stage Oracle collect the rows and return selection, In case of checking. Privilegesprocess Privileges checking. to the user simple execute. Execution plan checking Execution plan checking
Phases Parse Execute Fetch
Data table Files
Undo Segment
Emp
Control Files
Redo log Files
Database
Process behind DML statement
Instance
Server Process Shared Pool
Library
SGA
Emp Table
Database Redo log Buffer Cache
User Process
Phases Parse
Cache Buffer Cache
Data Dict
Execute
Prepare execution plan. In this case, Oracle locks the rows which are effected.
Cache
PMON
SMON
CKPT
DBWR
LGWR
ROLLBACK; Update from COMMIT; emp set sal = 2000 where deptno = 10;
Data Files
Undo Segment
Control Files
Redo log Files
Database
Read Consistency Mechanism
Instance
Server Process Shared Pool
Library Cache
SGA
Emp Table
Database Redo log Buffer Cache
User Process
Data Dict
20Buffer & 30
Cache
Scott 1
Cache
Select * from emp;
PMON SMON CKPT DBWR LGWR
Scott 2
Update from emp set sal = 2000 where deptno = 10;
Data Files
Undo Segment 10
Control Files
Redo log Files
Database
Function of PMON Process
Instance
Server Process Shared Pool
Library Cache Database Redo log Buffer Cache
SGA
Emp Table
User Process
Data Dict
Buffer Cache
Cache
Releasing Other resources. Releasing Locks.
PMON
SMON
CKPT
DBWR
LGWR
Rolling back the transaction. Update from
emp set sal = 2000 where deptno = 10;
Data Files
Undo Segment
Control Files
Redo log Files
Database
Function of SMON Process
Instance
Server Process Shared Pool
Library Cache Database Redo log Buffer Cache
SGA
Emp Table
User Process
Data Dict
Buffer Cache
Cache
PMON
SMON
CKPT
DBWR
LGWR
Commit;
SMON performs Instance recovery when database is reopened.
Data Files
Undo Segment
Control Files
Redo log Files
Database
Tuning SQL statement
Oracle Server uses the Library cache to store SQL and PL/SQL statement. To find whether a statement is already cached, the Oracle server Reduce the statement to the numeric value of the ASCII text.
Select empno, ename, job, sal from emp;
Converted in to ASCII text.
**************************************************
Tuning SQL statement
Select empno, ename from emp
Where deptno = 10;
Converted in to ASCII text.
**************************************************
Select empno, ename from emp
Where deptno = 20;
Converted in to ASCII text.
**************************************************
Select empno, ename from emp Where deptno = &deptno;
Converted in to ASCII text.
*************************************************
Questions