71
1- 1-1 Copyright Oracle Corporation, 1998, 2001. All rights reserved. Oracle DBA Course (9i, 10g, 11g) Lecture 1: Oracle Architectural Components

Resize sga

Embed Size (px)

Citation preview

Page 1: Resize sga

1-1-11 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Oracle DBA Course (9i, 10g, 11g)

Lecture 1:Oracle Architectural Components

Oracle DBA Course (9i, 10g, 11g)

Lecture 1:Oracle Architectural Components

Page 2: Resize sga

1-1-22 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Oracle DocumentationOracle Documentation

http://tahiti.oracle.com/

Page 3: Resize sga

1-1-33 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Objectives of the DBA courseObjectives of the DBA course

• Identify the various components of the Identify the various components of the Oracle architecture. Oracle architecture.

• Learn how to:Learn how to:

• sstart and shut down an Oracle databasetart and shut down an Oracle database,,

• ccreate an operational databasereate an operational database,,

• mmanage Oracle control files, redo log anage Oracle control files, redo log files, database files, tablespaces, files, database files, tablespaces, segments, extentssegments, extents,,

• mmanage users, privileges, and anage users, privileges, and resourcesresources,,

• uuse Globalization Support featuresse Globalization Support features..

Page 4: Resize sga

1-1-44 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Objectives of Lecture 1Objectives of Lecture 1

• Overview of Oracle server architecture, Overview of Oracle server architecture, identifying main components.identifying main components.

• Presentation of English and Polish Oracle Presentation of English and Polish Oracle server terminology.server terminology.

Page 5: Resize sga

1-1-55 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

The Oracle ServerThe Oracle Server

Server

Application/networkserver

Users

Oracle server

Page 6: Resize sga

1-1-66 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Oracle serverOracle server

The The Oracle serverOracle server consists of consists of::

• Oracle databaseOracle database - physical files that store

data

• Oracle instanceOracle instance - memory structures and

Oracle processes used to access data (from the

physical database files)

Page 7: Resize sga

1-1-77 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Oracle Database Oracle Database

An An Oracle databaseOracle database consists of operating system consists of operating system

files, known as files, known as database filesdatabase files, that provide , that provide

the actual physical storage for database the actual physical storage for database

information. The database files are used to information. The database files are used to

ensure that the data is kept consistent and can ensure that the data is kept consistent and can

be recovered in the event of a failure of the be recovered in the event of a failure of the

instance. instance.

Usually there is only one Oracle instance Usually there is only one Oracle instance

accessing a database. In the accessing a database. In the Real Application Real Application

ClusterCluster configuration multiple instances access configuration multiple instances access

a single database.a single database.

Page 8: Resize sga

1-1-88 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Oracle Database Physical Storage Structures

Oracle Database Physical Storage Structures

Control files

Redo logfiles

Data filesPasswordfile

Parameterfile

Archivedlog files

Database + Backup files, + Backup files, trace and alert trace and alert files, audit files, files, audit files, ……

Control and Control and redo log files redo log files are are multiplexedmultiplexed

Page 9: Resize sga

1-1-99 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Database

Other Key Physical StructuresOther Key Physical Structures

Archivedlog files

Passwordfile

Parameterfile

Page 10: Resize sga

1-1-1010 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Connecting to a DatabaseConnecting to a Database

UserUser

ClientClient ServerServerServerServer

processprocess

Oracle serverUserUserprocessprocess

Connection Connection establishedestablished

Session createdSession created

Page 11: Resize sga

1-1-1111 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

User ProcessUser Process

• Runs on the client machine

• Is spawned when a tool or an application is invoked

• Runs the tool or application (SQL*Plus, Oracle Enterprise Manager, OracleForms)

• Generates calls to the Oracle server

• Runs on the client machine

• Is spawned when a tool or an application is invoked

• Runs the tool or application (SQL*Plus, Oracle Enterprise Manager, OracleForms)

• Generates calls to the Oracle server

Page 12: Resize sga

1-1-1212 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

ConnectionConnection

ConnectionConnection is a communication pathway is a communication pathway between a user process and an Oracle between a user process and an Oracle Database instance. A communication pathway Database instance. A communication pathway is established using:is established using:

1.1. available interprocess communication available interprocess communication mechanisms (on a computer that runs both mechanisms (on a computer that runs both the user process and Oracle Database) or the user process and Oracle Database) or

2.2. network software (when different computers network software (when different computers run the database application and Oracle run the database application and Oracle Database, and communicate through a Database, and communicate through a network).network).

Page 13: Resize sga

1-1-1313 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

SessionSession

SessionSession is a specific connection of a user to an Oracle is a specific connection of a user to an Oracle Database instance through a user process. For example, Database instance through a user process. For example, when a user starts SQL*Plus, the user must provide a when a user starts SQL*Plus, the user must provide a valid user name and password, and then a session is valid user name and password, and then a session is established for that user. A session lasts from the time established for that user. A session lasts from the time the user connects until the time the user disconnects or the user connects until the time the user disconnects or exits the database application.exits the database application.

Multiple sessions can be created and exist concurrently Multiple sessions can be created and exist concurrently for a single Oracle Database user using the same user for a single Oracle Database user using the same user name. name.

• For example, a user with the user name/password of For example, a user with the user name/password of SCOTT/TIGER can connect to the same Oracle Database instance SCOTT/TIGER can connect to the same Oracle Database instance several times.several times.

Page 14: Resize sga

1-1-1414 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Server ProcessServer Process

• Runs on the server machine (host)

• Services a single user process in the dedicated server configuration

• Uses an exclusive Program Global Area (PGA)

• Processes calls generated by the client

• Returns results to the client

• Runs on the server machine (host)

• Services a single user process in the dedicated server configuration

• Uses an exclusive Program Global Area (PGA)

• Processes calls generated by the client

• Returns results to the client

Page 15: Resize sga

1-1-1515 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Oracle InstanceOracle Instance

Background processes

An Oracle instance:

• Is a means to access an Oracle database

• Always opens one and only one database

An Oracle instance:

• Is a means to access an Oracle database

• Always opens one and only one database

Instance

SGASGA - SGA -

System Global AreaSystem Global Area

Page 16: Resize sga

1-1-1616 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Oracle Memory StructuresOracle Memory Structures

+ Streams + Streams Pool in 10gPool in 10g

+ + ResResuult lt cachecache in 11g in 11g

Page 17: Resize sga

1-1-1717 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

System Global Area System Global Area (SGA)(SGA)System Global Area System Global Area (SGA)(SGA)

UUsed to store database information that is shared by sed to store database information that is shared by

database processes. It contains data and control database processes. It contains data and control

information for the Oracle server and is allocated in information for the Oracle server and is allocated in

the virtual memory of the computer where Oraclethe virtual memory of the computer where Oracle

resides. resides.

SHOW SGA;SHOW SGA;

Total System Global Area 36437964 bytes Total System Global Area 36437964 bytes

Fixed Size 6543794 bytes Fixed Size 6543794 bytes

Variable Size 19521536 bytes Variable Size 19521536 bytes

Database Buffers 16777216 bytes Database Buffers 16777216 bytes

Redo Buffers 73728 bytes Redo Buffers 73728 bytes

Page 18: Resize sga

1-1-1818 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Dynamic SGA Dynamic SGA Dynamic SGA Dynamic SGA

DDynamic SGA implements an infrastructure that ynamic SGA implements an infrastructure that

allows the SGA configuration to change without allows the SGA configuration to change without

shutting down the instance. This then allows shutting down the instance. This then allows

the sizes of the database buffer cache, the sizes of the database buffer cache, sshared hared

pool, and large pool to be changed without pool, and large pool to be changed without

shutting down the instance. Conceivably, theshutting down the instance. Conceivably, theyy

could be initially under configured and would could be initially under configured and would

grow and shrink depending upon their grow and shrink depending upon their

respective work loads, up to a maximum of respective work loads, up to a maximum of

SGA_MAX_SIZESGA_MAX_SIZE..

Page 19: Resize sga

1-1-1919 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Sizing the SGASizing the SGA Sizing the SGASizing the SGA

The size of the SGA is determined by several The size of the SGA is determined by several initialization parametersinitialization parameters, including, including::

DB_CACHE_SIZEDB_CACHE_SIZE: The size of the : The size of the defaultdefault cache of cache of databasedatabase blocks. blocks.

LOG_BUFFERLOG_BUFFER: The number of bytes allocated for : The number of bytes allocated for the redo log buffer cache.the redo log buffer cache.

SHARED_POOL_SIZESHARED_POOL_SIZE: The size in bytes of the : The size in bytes of the area devoted to shared SQL and PL/SQL.area devoted to shared SQL and PL/SQL.

LARGE_POOL_SIZELARGE_POOL_SIZE: The size of the large pool; : The size of the large pool; the default is zero.the default is zero.

Page 20: Resize sga

1-1-2020 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

System Global Area (SGA)System Global Area (SGA)System Global Area (SGA)System Global Area (SGA)

SGA memory allocated and tracked in SGA memory allocated and tracked in granules by SGA componentsgranules by SGA components..

A A granulegranule is a unit of contiguous is a unit of contiguous virtual memory allocation. The size of a virtual memory allocation. The size of a granule depends on the granule depends on the parameter parameter SGA_MAX_SIZE:SGA_MAX_SIZE:

– – 4 MB if estimated SGA size is < 128 MB4 MB if estimated SGA size is < 128 MB

– – 16 MB otherwise16 MB otherwise

Page 21: Resize sga

1-1-2121 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

The Shared PoolThe 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

• 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

Shared pool

Librarycache

Datadictionary

cache

Page 22: Resize sga

1-1-2222 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

ResizingResizing

The size of Shared PoolThe size of Shared Pool can be can be dynamically resized using ALTER SYSTEM dynamically resized using ALTER SYSTEM SET. After performance analysisSET. After performance analysis can be can be adjusted adjusted ((but the total SGA size cannot but the total SGA size cannot exceed SGA_MAX_SIZEexceed SGA_MAX_SIZE))::

ALTER SYSTEM SET ALTER SYSTEM SET SHARED_POOL_SIZE = 64M; SHARED_POOL_SIZE = 64M;

Page 23: Resize sga

1-1-2323 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Library CacheLibrary Cache

1. S1. Stores information about the most recently tores information about the most recently used SQL and PL/SQL statementsused SQL and PL/SQL statements::

• Enables the sharing of commonly used Enables the sharing of commonly used statements statements

2. 2. Consists of two structures: Consists of two structures:

• Shared SQL area Shared SQL area

• Shared PL/SQL area Shared PL/SQL area

3. 3. Has its size determined by the shared pool Has its size determined by the shared pool sizingsizing

Page 24: Resize sga

1-1-2424 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

The library cache consists of two structures: The library cache consists of two structures:

• • Shared SQLShared SQL: The Shared SQL stores and : The Shared SQL stores and shares the execution plan and parse tree for shares the execution plan and parse tree for SQL statements run against the database. The SQL statements run against the database. The second time that an identical SQL statement second time that an identical SQL statement is run, it is able to take advantage of the is run, it is able to take advantage of the parse information available in the shared SQL parse information available in the shared SQL to expedite its execution. To ensure that SQL to expedite its execution. To ensure that SQL statements use a shared SQL area whenever statements use a shared SQL area whenever possible, the text, schema, and bind possible, the text, schema, and bind variables must be exactly the same. variables must be exactly the same.

• • Shared PL/SQLShared PL/SQL: The shared PL/SQL area : The shared PL/SQL area stores and shares the most recently executed stores and shares the most recently executed PL/SQL statements. Parsed and compiled PL/SQL statements. Parsed and compiled program units and procedures (functions, program units and procedures (functions, packages, and triggers) are stored in this packages, and triggers) are stored in this area. area.

Page 25: Resize sga

1-1-2525 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Data Dictionary CacheData Dictionary Cache

ItIt is a collection of the most recently used is a collection of the most recently used definitions in the database. definitions in the database.

It includes information about database files, It includes information about database files, tables, indexes, columns, users, privileges, tables, indexes, columns, users, privileges, and other database oband other database objjects. ects.

During the parse phase, the server process During the parse phase, the server process looks at the data dictionary for information looks at the data dictionary for information to resolve to resolve objobject names and validate access. ect names and validate access.

Caching the data dictionary information into Caching the data dictionary information into memory improves response time on queries. memory improves response time on queries.

Size is determined by the shared pool sizing. Size is determined by the shared pool sizing.

Page 26: Resize sga

1-1-2626 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Sizing the Data DictionarySizing the Data Dictionary

The overall size is dependent on the size of The overall size is dependent on the size of the shared pool size and is managed the shared pool size and is managed internally by the database. If the data internally by the database. If the data dictionary cache is too small, then the dictionary cache is too small, then the database has to query the data dictionary database has to query the data dictionary tables repeatedly for information needed by tables repeatedly for information needed by the database. These queries are called the database. These queries are called recursive callsrecursive calls and are slower than the and are slower than the queries that are handled by the data queries that are handled by the data dictionary cache. dictionary cache.

Page 27: Resize sga

1-1-2727 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Database Buffer CacheDatabase Buffer Cache

• Stores the most recently used blocks that that have been retrieved from the data files.have been retrieved from the data files.

• DB_BLOCK_SIZEDB_BLOCK_SIZE determines the primary determines the primary block size. block size.

• Stores the most recently used blocks that that have been retrieved from the data files.have been retrieved from the data files.

• DB_BLOCK_SIZEDB_BLOCK_SIZE determines the primary determines the primary block size. block size.

Page 28: Resize sga

1-1-2828 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Multiple Block SizesMultiple Block Sizes

An Oracle database can be created An Oracle database can be created with a standard block size and up to with a standard block size and up to four non-standard block sizes. Non-four non-standard block sizes. Non-standard block sizes can have any standard block sizes can have any power-of-two value between 2 KB and power-of-two value between 2 KB and 32 KB. 32 KB.

Page 29: Resize sga

1-1-2929 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Database Buffer CacheDatabase Buffer Cache

Consists of Consists of three three independent sub-caches: independent sub-caches:

• DEFAULTDEFAULT Buffer Pool - Buffer Pool - DB_CACHE_SIZEDB_CACHE_SIZE

• KEEPKEEP Buffer Pool - Buffer Pool - DB_KEEP_CACHE_SIZEDB_KEEP_CACHE_SIZE

• RECYCLERECYCLE Buffer Pool - Buffer Pool - DB_RECYCLE_CACHE_SIZEDB_RECYCLE_CACHE_SIZE

Database buffer cache can be dynamically Database buffer cache can be dynamically resized to grow or shrink using ALTER SYSTEMresized to grow or shrink using ALTER SYSTEM

ALTER SYSTEM SET DB_CACHE_SIZE = 96M; ALTER SYSTEM SET DB_CACHE_SIZE = 96M;

Page 30: Resize sga

1-1-3030 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Buffer Cache Advisory ParameterBuffer Cache Advisory Parameter

DB_CACHE_ADVICEDB_CACHE_ADVICE can be set to gather can be set to gather statistics for predicting different cache size statistics for predicting different cache size behaviorbehavior (values(values:: OFFOFF, , READYREADY, , ONON))..

The information provided by these statistics The information provided by these statistics can help DBA size the buffer cache optimally can help DBA size the buffer cache optimally for a given workload. for a given workload.

The buffer cache advisory information is The buffer cache advisory information is collected and displayed through the collected and displayed through the V$DB_CACHE_ADVICEV$DB_CACHE_ADVICE view view..

Page 31: Resize sga

1-1-3131 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Types of buffersTypes of buffers

DirtyDirty - changed and has not yet been written to the - changed and has not yet been written to the disk.disk.

ColdCold - - that has not been recently used according to the least recently used (LRU) algorithm.

FreeFree - contain no data or are free to be overwritten. - contain no data or are free to be overwritten.

PinnedPinned - currently being accessed or explicitely - currently being accessed or explicitely retained for future use (e.g. the KEEP buffer pool).retained for future use (e.g. the KEEP buffer pool).

Page 32: Resize sga

1-1-3232 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Two lists of buffersTwo lists of buffers

Write listWrite list (dirty buffer list) - buffers that are (dirty buffer list) - buffers that are modified and need to be written to the disk.modified and need to be written to the disk.

Least recently used listLeast recently used list (LRU) - free buffers, (LRU) - free buffers, pinned buffers and the dirty buffers that have pinned buffers and the dirty buffers that have not yet been moved to the Write List. The most not yet been moved to the Write List. The most recently accessed blocks are always in the recently accessed blocks are always in the frontfront ((MRU endMRU end)); the least recently accessed blocks, ; the least recently accessed blocks, in the in the endend ( (LRU endLRU end))..

Page 33: Resize sga

1-1-3333 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

LRU listLRU list

The least-used blocks are thrown out of the list The least-used blocks are thrown out of the list when new blocks are accessed and added to the when new blocks are accessed and added to the MRU end of the list. With one exception – when a MRU end of the list. With one exception – when a full table is scanned – the blocks are written to the full table is scanned – the blocks are written to the LRU end of the list.LRU end of the list.

When an Oracle process accesses a buffer, it When an Oracle process accesses a buffer, it moves the buffer to the MRU end of the list so that moves the buffer to the MRU end of the list so that the most frequently accessed data is available in the most frequently accessed data is available in the buffers.the buffers.

Page 34: Resize sga

1-1-3434 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

LRU listLRU list

When an Oracle process requests data, it searches When an Oracle process requests data, it searches the data in the buffer cache – if the data in the buffer cache – if it it finds,finds, we get we get cache hitcache hit. If not – . If not – cache misscache miss – data needs to be – data needs to be copied from disk to the buffer.copied from disk to the buffer.

The server process searchesThe server process searches (from the LRU end) (from the LRU end) until it finds a free buffer or until it has searched a until it finds a free buffer or until it has searched a threshold limit of buffers. It moves encountered threshold limit of buffers. It moves encountered dirty buffers to the write list. If it does not find a dirty buffers to the write list. If it does not find a free buffer – DBWn writes some buffers from write free buffer – DBWn writes some buffers from write list to disk – making available free buffers for the list to disk – making available free buffers for the server process.server process.

Page 35: Resize sga

1-1-3535 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Redo Log Buffer CacheRedo Log Buffer Cache

• Size defined by LOG_BUFFER

• Records changes made through the instance

• Used sequentially

• Circular buffer

• Size defined by LOG_BUFFER

• Records changes made through the instance

• Used sequentially

• Circular buffer

Page 36: Resize sga

1-1-3636 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Redo Log Buffer CacheRedo Log Buffer Cache

• The redo log buffer cache records all The redo log buffer cache records all changes made to the database data blocks. changes made to the database data blocks.

• Its primary purpose is Its primary purpose is recoveryrecovery. .

• Changes recorded within are called Changes recorded within are called redo redo entriesentries. .

• Redo entries contain information to Redo entries contain information to reconstruct or redo changes. reconstruct or redo changes.

Page 37: Resize sga

1-1-3737 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

ResResuult cachelt cache (11g) (11g)ResResuult cachelt cache (11g) (11g)

The The result cacheresult cache buffers query results. If a buffers query results. If a query is run that already has results in the query is run that already has results in the result cache, the database returns results from result cache, the database returns results from the result cache instead of rerunning the query. the result cache instead of rerunning the query. This speeds up the execution of frequently run This speeds up the execution of frequently run queries.queries.

The database automatically invalidates a The database automatically invalidates a cached result whenever a transaction modifies cached result whenever a transaction modifies the data or metadata of any of the database the data or metadata of any of the database objects used to construct that cached result.objects used to construct that cached result.

Page 38: Resize sga

1-1-3838 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Result cache (11g)Result cache (11g)

Users can annotate a query or query fragment Users can annotate a query or query fragment with a with a result cache hintresult cache hint to indicate that results to indicate that results are to be stored in the SQL query result cache.are to be stored in the SQL query result cache.

You can set the RESULT_CACHE_MODE You can set the RESULT_CACHE_MODE initialization parameter to control whether the initialization parameter to control whether the SQL query result cache is used for all queries SQL query result cache is used for all queries (when possible), or only for queries that are (when possible), or only for queries that are annotated.annotated.

Page 39: Resize sga

1-1-3939 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

PL/SQL Function Result CachePL/SQL Function Result Cache

A PL/SQL function may depend on several parameters. In A PL/SQL function may depend on several parameters. In some cases, the SQL statements in the function body some cases, the SQL statements in the function body access data (for example, the catalog of wares in a access data (for example, the catalog of wares in a shopping application) that changes very infrequently shopping application) that changes very infrequently compared to the frequency of calling the function. compared to the frequency of calling the function.

The look-up key for the cache is the combination of The look-up key for the cache is the combination of actual arguments with which the function is invoked. actual arguments with which the function is invoked. When a particular invocation of the result-cached When a particular invocation of the result-cached function is a cache hit, then the function body is not function is a cache hit, then the function body is not executed; instead, the cached value is returned executed; instead, the cached value is returned immediately.immediately.

Page 40: Resize sga

1-1-4040 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Large PoolLarge Pool

The The large poollarge pool is an optional area of memory is an optional area of memory in the SGA configured only in a shared server in the SGA configured only in a shared server environment. environment.

It relieves the burden placed on the shared It relieves the burden placed on the shared pool. pool.

This configured memory area is used forThis configured memory area is used for session memory (UGA), I/O slaves, and backup session memory (UGA), I/O slaves, and backup and restore operations. and restore operations.

Unlike the shared pool, the large pool does Unlike the shared pool, the large pool does not use an LRU list. not use an LRU list.

Sized by Sized by LARGE_POOL_SIZELARGE_POOL_SIZE

ALTER SYSTEM SET LARGE_POOL_SIZE = 64M; ALTER SYSTEM SET LARGE_POOL_SIZE = 64M;

Page 41: Resize sga

1-1-4141 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Java PoolJava Pool

The The Java poolJava pool services the parsing services the parsing requirements for Java commands. requirements for Java commands.

Required if installing and using Java. Required if installing and using Java.

It is sized by the It is sized by the JAVA_POOL_SIZEJAVA_POOL_SIZE parameter. parameter.

In Oracle9i, the default size of the Java In Oracle9i, the default size of the Java Pool Pool is 24M. is 24M.

Page 42: Resize sga

1-1-4242 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Streams Pool (10g)Streams Pool (10g)

Oracle Streams enables information sharing. Oracle Streams enables information sharing.

Using Oracle Streams, each unit of shared Using Oracle Streams, each unit of shared

information is called a message, and you can information is called a message, and you can

share these messages in a share these messages in a streamstream. The stream . The stream

can propagate information within a database or can propagate information within a database or

from one database to another. The stream from one database to another. The stream

routes specified information to specified routes specified information to specified

destinations. destinations. They are used forThey are used for distributed distributed

databasdatabaseses, , applicationsapplications and and data warehouses. data warehouses.

The size of the Streams pool starts at zero. The size of the Streams pool starts at zero.

The pool size grows dynamically as needed.The pool size grows dynamically as needed.

Page 43: Resize sga

1-1-4343 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Program Global Area (PGA)Program Global Area (PGA)

• Not shared

Contains:

• Sort areaSORT_AREA_SIZE

– Sort area size can grow depending on the need.

• Session information

• Cursor state

• Stack space

• Not shared

Contains:

• Sort areaSORT_AREA_SIZE

– Sort area size can grow depending on the need.

• Session information

• Cursor state

• Stack space

PGAServerServerprocessprocess

MMemory region that emory region that contains data and control contains data and control information for a single information for a single server process or a single server process or a single background process. The background process. The PGA is allocated when a PGA is allocated when a process is created and process is created and deallocated when the deallocated when the process is terminated. process is terminated.

Page 44: Resize sga

1-1-4444 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

PGAPGA

The total memory used by all individual PGAs The total memory used by all individual PGAs is known as the is known as the total instance PGA memorytotal instance PGA memory, , and the collection of individual PGAs is and the collection of individual PGAs is referred to as the total instance PGA, or just referred to as the total instance PGA, or just instance PGAinstance PGA. With Oracle Enterprise Manager . With Oracle Enterprise Manager Database Control, you set the size of the Database Control, you set the size of the instance PGA, not individual PGAs.instance PGA, not individual PGAs.

Page 45: Resize sga

1-1-4545 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

SummarySummary

Page 46: Resize sga

1-1-4646 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Oracle ProcessesOracle Processes

+ Management + Management Monitor Monitor MMON in 11gMMON in 11g

Page 47: Resize sga

1-1-4747 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Server processServer process

Oracle Database creates server processes to handle the Oracle Database creates server processes to handle the requests of user processes connected to the instance. In requests of user processes connected to the instance. In some situations when the application and Oracle some situations when the application and Oracle Database operate on the same computer, it is possible to Database operate on the same computer, it is possible to combine the user process and corresponding server combine the user process and corresponding server process into a single process to reduce system process into a single process to reduce system overhead. overhead.

However, when the application and Oracle Database However, when the application and Oracle Database operate on different computers, a user process always operate on different computers, a user process always communicates with Oracle Database through a separate communicates with Oracle Database through a separate server process.server process.

Page 48: Resize sga

1-1-4848 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Server processServer process

Server processes (or the server portion of combined Server processes (or the server portion of combined user/server processes) created on behalf of each user's user/server processes) created on behalf of each user's application can perform one or more of the following:application can perform one or more of the following:

• Parse and run SQL statements issued through the Parse and run SQL statements issued through the applicationapplication

• Read necessary data blocks from datafiles on disk into Read necessary data blocks from datafiles on disk into the shared database buffers of the SGA, if the blocks are the shared database buffers of the SGA, if the blocks are not already present in the SGAnot already present in the SGA

• Return results in such a way that the application can Return results in such a way that the application can process the informationprocess the information

Page 49: Resize sga

1-1-4949 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Instance

SGA Shared pool

DBWR

Database buffercache

Database Writer (DBWn, n=0,…,19)Database Writer (DBWn, n=0,…,19)

Control files

Redo logfiles

Data files

Page 50: Resize sga

1-1-5050 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

The server process records changes to The server process records changes to rollback and data blocks in the buffer rollback and data blocks in the buffer cache. cache. Database WriterDatabase Writer (DBWn) writes (DBWn) writes the the cold, cold, dirty buffers from the dirty buffers from the database buffer cache to the data database buffer cache to the data files. It ensures that a sufficient files. It ensures that a sufficient number of free buffersnumber of free buffers —— buffers that buffers that can be overwritten when server can be overwritten when server processes need to read in blocks from processes need to read in blocks from the data filesthe data files —are available in the —are available in the database buffer cache. Database database buffer cache. Database performance is improved because server performance is improved because server processes make changes only in the processes make changes only in the buffer cache. buffer cache.

Page 51: Resize sga

1-1-5151 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

DBWnDBWn defers writing to the data files until defers writing to the data files until one of the following events occurs: one of the following events occurs:

• • CCheckpoint heckpoint

• • The number of dirty buffers reaches a The number of dirty buffers reaches a threshold value threshold value

• • A process scans a specified number of blocks A process scans a specified number of blocks when scanning for free buffers and cannot finwhen scanning for free buffers and cannot findd any. any.

• • Placing a tablespace in read onlyPlacing a tablespace in read only or offline or offline mode. mode.

• • Dropping or Dropping or ttruncating a table. runcating a table.

• • ALTER TABLESPACE ALTER TABLESPACE tablespacetablespace__namename BEGIN BACKUP BEGIN BACKUP;;

Page 52: Resize sga

1-1-5252 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Instance

SGA Shared pool

Redo logbuffer

LGWR

Log Writer (LGWR)Log Writer (LGWR)

Control files

Redo logfiles

Data files

Page 53: Resize sga

1-1-5353 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

LGWRLGWR performs sequential writes from the redo log performs sequential writes from the redo log buffer cache to the redo log file under the buffer cache to the redo log file under the following situations: following situations:

• • When a transaction commits When a transaction commits

• • When the redo log buffer cache is one-third full When the redo log buffer cache is one-third full

• • When there is more than a megabyte of changes When there is more than a megabyte of changes records in the redo log buffer cache records in the redo log buffer cache

• • Before DBWn writes modified blocks in the Before DBWn writes modified blocks in the database buffer cache to the data files database buffer cache to the data files

• • Every 3 seconds. Every 3 seconds.

Because the redo is needed for recovery, LGWR Because the redo is needed for recovery, LGWR confirms the commit only after the redo isconfirms the commit only after the redo is written written to disk.to disk.

Page 54: Resize sga

1-1-5454 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Shared pool

Redo logbuffer

LGWR

Control files

Redo logfiles

Data files

Database

COMMIT ProcessingCOMMIT Processing

ServerServerprocessprocess

1

2UserUser

processprocess

3

Database buffercache4

SGA

Instance

SCN - SCN - System Change NumberSystem Change Number - - represents the state of data after represents the state of data after the COMMIT - assigned to data the COMMIT - assigned to data blocks.blocks.

Page 55: Resize sga

1-1-5555 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

System Monitor (SMON)

System Monitor (SMON)

If the Oracle instance fails, any information If the Oracle instance fails, any information in the SGA that has not been written to disk in the SGA that has not been written to disk is lost. For example, the failure of the is lost. For example, the failure of the operating system causes an instance failure. operating system causes an instance failure.

After the loss of the instance, the After the loss of the instance, the background process SMON automatically background process SMON automatically performs instance recovery when the database performs instance recovery when the database is reopened. is reopened.

Page 56: Resize sga

1-1-5656 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

1. 1. Rolling forwardRolling forward to recover data that has not to recover data that has not been recorded in the data files but that has been been recorded in the data files but that has been recorded in the online redo log. This data has not recorded in the online redo log. This data has not been written to disk because of the loss of the been written to disk because of the loss of the SGA during instance failure. During this process, SGA during instance failure. During this process, SMON reads the redo log files and applies the SMON reads the redo log files and applies the changes recorded in the redo log to the data changes recorded in the redo log to the data blocks. Because all committed transactions have blocks. Because all committed transactions have been written to the redo logs, this process been written to the redo logs, this process completely recovers these transactions. completely recovers these transactions.

2. 2. Opening the databaseOpening the database so that users can log on. so that users can log on. Any data that is not locked byAny data that is not locked by unrecovered unrecovered transactions is immediately available.transactions is immediately available.

3. 3. Rolling backRolling back uncommitted transactions. They are uncommitted transactions. They are rolled back by SMON or by the individual server rolled back by SMON or by the individual server processes as they access locked data. processes as they access locked data.

Page 57: Resize sga

1-1-5757 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Process Monitor (PMON)

Process Monitor (PMON)

The background process The background process PMONPMON cleans up after cleans up after failed processes by: failed processes by:

• • Rolling back the user’s current transaction Rolling back the user’s current transaction

• • Releasing all currently held table or row Releasing all currently held table or row locks locks

• • Freeing other resources currently reserved Freeing other resources currently reserved by the user by the user

Page 58: Resize sga

1-1-5858 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Checkpoint Event

Checkpoint Event

An event called a An event called a checkpointcheckpoint :::: the Oracle the Oracle background process DBWn writes all the background process DBWn writes all the modified database buffers in the SGA, modified database buffers in the SGA, including both committed and uncommitted data, including both committed and uncommitted data, to the data files. to the data files. Helps to reduce the time Helps to reduce the time required for instance recovery.required for instance recovery.

Page 59: Resize sga

1-1-5959 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Checkpoint Process (CKPT)Checkpoint Process (CKPT)

• • Writes cWrites checkpoint number into the heckpoint number into the data file headers data file headers

• • Writes cWrites checkpoint number, log heckpoint number, log sequence number, archived log names, sequence number, archived log names, and system change numbers into the and system change numbers into the control file. control file.

CKPT CKPT itself itself does not write data blocks does not write data blocks to disk or redo blocks to the online to disk or redo blocks to the online redo logsredo logs - DBWn does - DBWn does. .

Page 60: Resize sga

1-1-6060 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Archiver (ARCn)Archiver (ARCn)

Optional background process Optional background process whichwhich aautomatically archives online redo utomatically archives online redo logs when ARCHIVELOG logs when ARCHIVELOG mode is setmode is set

Preserves the record of all changes Preserves the record of all changes made to the made to the databasedatabase

Page 61: Resize sga

1-1-6161 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

ARCnARCn, is crucial to recovering a database , is crucial to recovering a database after the loss of a disk. As online redo log after the loss of a disk. As online redo log files fill, the Oracle server begins writing files fill, the Oracle server begins writing to the next online redo log file. The process to the next online redo log file. The process of switching from one redo log to another is of switching from one redo log to another is called a called a log switchlog switch. The ARCn process . The ARCn process initiates backing up, or archiving, of the initiates backing up, or archiving, of the filled log group at every log switch. It filled log group at every log switch. It automatically archives the online redo log automatically archives the online redo log before the log can be reused, so that all of before the log can be reused, so that all of the changes made to the database are the changes made to the database are preserved. This enables the DBA to recover the preserved. This enables the DBA to recover the database to the point of database to the point of ffailure, even if a ailure, even if a disk drive is damaged. disk drive is damaged.

Page 62: Resize sga

1-1-6262 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

NOARCHIVELOG modeNOARCHIVELOG mode

TThe online redo log files arehe online redo log files are overwritten each time a log switch overwritten each time a log switch occurs. LGWR does not overwrite a redo occurs. LGWR does not overwrite a redo log group until log group until the checkpoint for that the checkpoint for that group is completegroup is complete. This ensures that . This ensures that committed data can be recovered if committed data can be recovered if there is an instance crash. During the there is an instance crash. During the instance crash, only the SGA is lost. instance crash, only the SGA is lost. There is no loss of disks, only memory. There is no loss of disks, only memory. For example, an operating system crash For example, an operating system crash causes an instance crash. causes an instance crash.

Page 63: Resize sga

1-1-6363 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Dispatcher (Dnnn)Dispatcher (Dnnn)

Part of the shared server architecture. They Part of the shared server architecture. They minimize the resource needs by handling minimize the resource needs by handling multiple connections to the database using a multiple connections to the database using a limited number of server processes.limited number of server processes.

When a user makes a request, the dispatcher When a user makes a request, the dispatcher places the request on the request queue.places the request on the request queue.

Page 64: Resize sga

1-1-6464 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Shared Server (Snnn)Shared Server (Snnn)

Shared server serves multiple user processes.Shared server serves multiple user processes.

When the instance starts, Oracle starts a fixed When the instance starts, Oracle starts a fixed number of server processes working in a round-number of server processes working in a round-robin fashion to serve requests from the user robin fashion to serve requests from the user processes - placed by the dispatcher into the processes - placed by the dispatcher into the request queue. request queue.

The results are put into the response queue, to The results are put into the response queue, to be taken by the dispatcher.be taken by the dispatcher.

Page 65: Resize sga

1-1-6565 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Job Queue Processes Job Queue Processes

Job queue processes are used for batch Job queue processes are used for batch processing. They run processing. They run user jobsuser jobs. They can be . They can be viewed as a scheduler service that can be used viewed as a scheduler service that can be used to schedule jobs as PL/SQL statements or to schedule jobs as PL/SQL statements or procedures on an Oracle Database instance. procedures on an Oracle Database instance. Given a start date and an interval, the job queue Given a start date and an interval, the job queue processes try to run the job at the next processes try to run the job at the next occurrence of the interval.occurrence of the interval.

Page 66: Resize sga

1-1-6666 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Logical storage structures

Logical storage structures

•• A A segmentsegment is made up of is made up of extentsextents. .

• • An An extentextent is made up of logical is made up of logical contiguous contiguous blocksblocks allocated in one chunkallocated in one chunk. .

• • A A blockblock is the smallest unit for read and write is the smallest unit for read and write operationsoperations - a multiple of the SO block size - a multiple of the SO block size..

• An An Oracle databaseOracle database is a is a group ofgroup of tablespacestablespaces. .

• • A A tablespacetablespace may consist of may consist of one or more one or more segmentssegments.. At At least: SYSTEM least: SYSTEM ((in 10g also in 10g also SYSAUX).SYSAUX).

Page 67: Resize sga

1-1-6767 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Logical/physical/recovery-related structures of the database

Logical/physical/recovery-related structures of the database

Page 68: Resize sga

1-1-6868 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Types of segmentsTypes of segments

Data segmentsData segments - store the table (or cluster) data. - store the table (or cluster) data.

Index segmentsIndex segments - store the index data. - store the index data.

Temporary segmentsTemporary segments - temporary work area e.g. - temporary work area e.g. for sorting, executing SQL statements.for sorting, executing SQL statements.

Undo (rollback) segmentsUndo (rollback) segments - store undo - store undo information. When you roll back changes made information. When you roll back changes made to the database, undo records in the undo to the database, undo records in the undo tablespace are used to undo the changes.tablespace are used to undo the changes.

Page 69: Resize sga

1-1-6969 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Undo (Rollback) SegmentUndo (Rollback) Segment

DML DML statementstatement

Old Old imageimage

New New imageimage

Undo Undo segmentsegment

TableTable

Page 70: Resize sga

1-1-7070 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Review of physical storage structuresReview of physical storage structures

Data filesData files - contain all the database data. Each data file is - contain all the database data. Each data file is associated with one and only one tablespace.associated with one and only one tablespace.

Redo log filesRedo log files - record changes made to data. There must - record changes made to data. There must be at least 2 redo log files because of a circular fashion of be at least 2 redo log files because of a circular fashion of using them. If a failure prevents the database change from using them. If a failure prevents the database change from being written to a data file, the changes can be obtained being written to a data file, the changes can be obtained from the redo log files. from the redo log files. Multiplexing of redo logsMultiplexing of redo logs - - maintaining mutiple copies of redo log files (preferably on maintaining mutiple copies of redo log files (preferably on distinct disks) - called a distinct disks) - called a redo log groupredo log group..

Control filesControl files - basic information about the physical - basic information about the physical structure of the database such as the database name, structure of the database such as the database name, locations of every data file and redo log file (usually locations of every data file and redo log file (usually multiplexed).multiplexed).

Page 71: Resize sga

1-1-7171 Copyright Oracle Corporation, 1998, 2001. All rights reserved.

Instance

SGA Shared pool

DBWR LGWR

Database

Control files

Data files Redo logfiles

UserUserprocessprocess

ServerServerprocessprocess

PGA

SummarySummary

Passwordfile

Archivedlog files

Parameterfile