280 likes | 402 Views
Oracle Architectural Components. Objectives. Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing a query Listing the stages in processing a DML statement Listing the stages in processing COMMITS. Oracle server. The Oracle Server.
E N D
Objectives • Listing the structures involved in connecting a user to an Oracle server • Listing the stages in processing a query • Listing the stages in processing a DML statement • Listing the stages in processing COMMITS
Oracle server The Oracle Server Application/networkserver Server Users
Oracle server Connecting to a Database Serverprocess Client Server Userprocess User
User Process • Runs on the client machine • Is spawned when a tool or an application is invoked • Runs the tool or application (SQL*Plus, Server Manager, Oracle Enterprise Manager, Developer/2000) • Includes the User Program Interface (UPI) • Generates calls to the Oracle server
Server Process • Runs on the server machine (host) • Services a single user process in the dedicated server configuration • Uses an exclusive PGA • Includes the Oracle Program Interface (OPI) • Processes calls generated by the client • Returns results to the client
Instance SGA Oracle Instance An Oracle instance: • Is a means to access an Oracle database • Always opens one and only one database Background processes
Control files Data files Redo logfiles Oracle Database Parameterfile Archivedlog files Passwordfile Database
Parameterfile Passwordfile Archivedlog files Other Key Physical Structures Database
Processing a Query • Parse: • - Search for identical statement • Check syntax, object names, privileges • Lock objects used during parse • Create and store execution plan • Execute: identify rows selected • Fetch: return rows to user process
Statement Handle Handle Results OK OK • Parse • Execute • Fetch Processing a Query (cont.) SELECT * FROM emp ORDER BY ename; Userprocess Serverprocess
Shared pool Librarycache Datadictionarycache The Shared Pool • Size defined by SHARED_POOL_SIZE • Library cache contains statement text, parsed code, and an execution plan • Data dictionary cache contains table and column definitions and privileges
Database Buffer Cache • Number of buffers defined by DB_BLOCK_BUFFERS • Size of a buffer based on DB_BLOCK_SIZE • Stores the most recently used blocks
Program Global Area (PGA) PGA Serverprocess • Not shared and not writable • Contains • Sort area • Session information • Cursor state • Stack space
Processing a DML Statement • If data blocks not in the buffer, server process reads them into the buffer • Server process places locks on rows to be modified • The redo log buffer is modified with the changed values • The data blocks are changed • Before image is recorded in the rollback block
3 Instance SGA 4 Shared pool Librarycache 5 Database buffercache Redo logbuffer Datadictionarycache 2 Control files Data files Redo logfiles 1 Database Processing a DML Statement (cont.) UPDATE emp SET sal=sal*1.1 WHERE empno=7369 Serverprocess
Rollback Segment Old image New image Table Rollback segment DML statement
Redo Log Buffer • Size defined by LOG_BUFFER • Records changes made through the instance • Used sequentially • Circular buffer
Other Instance Processes • Other required processes • - Database Write (DBW0) • - Log Writer (LGWR) • - Process Monitor (PMON) • - System Monitor (SMON) • - Checkpoint (CKPT) • Archive process (ARC0) is optional; is used in production database
Instance SGA Shared pool Database buffercache DBWR Data files Control files Redo logfiles Database Writer (DBWR) • DBW0 writes when: • There are many dirty buffers • There are few free buffers • Timeout occurs • Checkpoint occurs
Instance SGA Shared pool Redo logbuffer LGWR Data files Control files Redo logfiles Log Writer (LGWR) • LGWR writes when: • There is a commit • The redo log buffer is one-third full • There is more than 1MB of redo • Before DBW0 writes
COMMIT Processing • Server process places a commit record and system change number (SCN) in redo log buffer. • LGWR writes redo log to redo log files. • User is informed COMMIT is complete • Server process records trans. Is complete and locks can be released.
1 4 3 2 Control files Data files Redo logfiles Database COMMIT Processing (cont.) Instance SGA Shared pool Serverprocess Database buffercache Redo logbuffer LGWR Userprocess
SMON: System Monitor • Automatically recovers the instance • Rolls forward changes in redo logs • Opens the database for user access • Rolls back uncommitted transactions • Coalesces free spaces • Deallocates temporary segments
PMON: Process Monitor • Cleans up after failed processes by: • Rolling back the transaction • Releasing locks • Releasing other resources
Archiving • Database archive mode • - NOARCHIVELOG for databases that do not require recovery after disk failure • - ARCHIVELOG mode for production • ARC0 process • Automatically archives online redo log files • Preserves the record of all changes made to the database
Instance SGA Shared pool DBWR LGWR Control files Parameterfile Archivedlog files Redo logfiles Data files Passwordfile Summary Serverprocess PGA Userprocess Database
Summary (cont.) • You should have learned: • Explain the SGA, Instance, memory structures • Explain the database files • Explain the primary background processes (DBW0, LGWR, CKPT, PMON, SMON, ARC0) • Explain SQL processing steps • Explain the COMMIT process