The shared pool portion of the SGA contains the library cache, the dictionary cache, buffers for parallel execution messages, and control structures.
The total size of the shared pool is determined by the initialization parameterSHARED_POOL_SIZE
. The default value of this parameter is 8MB on 32-bit platforms and 64MB on 64-bit platforms. Increasing the value of this parameter increases the amount of memory reserved for the shared pool.
The library cache includes the shared SQL areas, private SQL areas (in the case of a shared server configuration), PL/SQL procedures and packages, and control structures such as locks and library cache handles.
Shared SQL areas are accessible to all users, so the library cache is contained in the shared pool within the SGA.
因为Shared SQL areas要被所有用户访问,所以包含了Shared SQL areas的library cache要位于SGA上的shared pool中。
注释:
Memory Area |
Dedicated Server |
Shared Server |
Nature of session memory |
Private |
Shared |
Location of the persistent area |
PGA |
SGA |
Location of part of the run-time area for |
PGA |
PGA |
Location of the run-time area for DML/DDL statements |
PGA |
PGA |
Oracle represents each SQL statement it runs with a shared SQL area and a private SQL area.Oracle recognizes when two users are executing the same SQL statement and reuses the shared SQL area for those users. However, each user must have a separate copy of the statement's private SQL area.
A shared SQL area contains the parse tree and execution plan for a given SQL statement.(即Shared SQL Areas存放执行计划、sql语句的文本等,而"Private SQL Area存放其对应的一个会话里执行的该SQL语句执行时的具体的绑定变量等) Oracle saves memory by using one shared SQL area for SQL statements run multiple times,which often happens when many users run the same application.
Oracle allocates memory from the shared pool when a new SQL statement is parsed, to store in the shared SQL area. The size of this memory depends on the complexity of the statement.If the entire shared pool has already been allocated, Oracle can deallocate items from the pool using a modified LRU (least recently used) algorithm until there is enough free space for the new statement's shared SQL area. If Oracle deallocates a shared SQL area, the associated SQL statement must be reparsed and reassigned to another shared SQL area at its next execution.
See Also:
"Private SQL Area"
Oracle Database Performance Tuning Guide
Oracle processes PL/SQL program units (procedures, functions, packages, anonymous blocks, and database triggers) muchthe same way it processes individual SQL statements. Oracle allocates a shared areato hold the parsed, compiled form of a program unit. Oracle allocates a private area to hold values specific to the session that runs the program unit, including local, global, and package variables (also known as package instantiation) and buffers for executing SQL. If more than one user runs the same program unit, then a single, shared area is used by all users, while each user maintains a separate copy of his or her private SQL area, holding values specific to his or her session.
Individual SQL statements contained within a PL/SQL program unit are processed as described in the previous sections. Despite their origins within a PL/SQL program unit, these SQL statements use a shared area to hold their parsed representations and a private area for each session that runs the statement.
总结注释:
一个会话里如果处理的是SQL语句,那么在shared pool中就有该SQL语句对应的Shared Areas,该Shared Areas的类型为Shared SQL Areas,在该会话对应的进程对应的uga中,就有该SQL语句对应的Private Areas,该Private Areas的类型为Private SQL Areas。当然由于当一个SQL语句执行完毕后它对应的Private SQL Area也会释放掉,又一个会话里同时只有一个SQL语句执行,所以该会话对应的进程对应的uga中始终最多只有一个Private SQL Area存在。
一个会话里如果处理的是 PL/SQL program units,那么在shared pool中就有该 PL/SQL program units对应的Shared Areas,该Shared Areas的类型为SharedPL/SQL Areas,在该会话对应的进程对应的uga中,就有该SQL语句对应的Private Areas,该Private Areas的类型为PrivatePL/SQL Areas。当然由于当一个PL/SQL program units执行完毕后它对应的Private SQL Area也会释放掉,又一个会话里同时只有一个PL/SQL program units执行,所以该会话对应的进程对应的uga中始终最多只有一个PrivatePL/SQL Areas存在。
The data dictionary is a collection of database tables and views containing reference information about the database, its structures, and its users. Oracle accesses the data dictionary frequently during SQL statement parsing. This access is essential to the continuing operation of Oracle.
The data dictionary is accessed so often by Oracle that two special locations in memory are designated to hold dictionary data. One area is called the data dictionary cache, also known as the row cache because it holds data as rows instead of buffers (which hold entire blocks of data).The other area in memory to hold dictionary data isthe library cache. All Oracle user processes share these two caches for access to data dictionary information.
注释:
上述说明,一个 buffer存储一整个 block的数据,而row cache只是从数据文件里的block上读取一行它所需的数据行。
See Also:
Chapter 7, "The Data Dictionary"
"Library Cache"
参考:
http://docs.oracle.com/cd/B19306_01/server.102/b14220/memory.htm#sthref1339
Oracle® Database Concepts 10g Release 2 (10.2) B14220-02 |
|
|
PDF ·Mobi · ePub |
This chapter discusses the memory architecture of an Oracle instance.
This chapter contains the following topics:
Introduction to Oracle Memory Structures
Overview of the System Global Area
Overview of the Program Global Areas
Dedicated and Shared Servers
Software Code Areas