Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005
CHAPTER 4 ■ MEMORY STRUCTURES 151 The Large pool is used specifically by • Shared server connections, to allocate the UGA region in the SGA • Parallel execution of statements, to allow for the allocation of interprocess message buffers, which are used to coordinate the parallel query servers • Backup for RMAN disk I/O buffers in some cases As you can see, none of these memory allocations should be managed in an LRU buffer pool designed to manage small chunks of memory. With shared server connection memory, for example, once a session logs out, this memory is never going to be reused, so it should be immediately returned to the pool. Also, shared server UGA memory allocation tends to be “large.” If you review the earlier examples with the SORT_AREA_RETAINED_SIZE or PGA_ AGGREGATE_TARGET, the UGA can grow very large and is definitely bigger than 4KB chunks. Putting MTS memory into the Shared pool causes it to fragment into odd-sized pieces of memory and, furthermore, you will find that large pieces of memory that will never be reused will age out memory that could be reused. This forces the database to do more work to rebuild that memory structure later. The same is true for parallel query message buffers, since they are not LRU manageable. They are allocated and cannot be freed until they are done being used. Once they have delivered their message, they are no longer needed and should be released immediately. With backup buffers, this applies to an even greater extent—they are large, and once Oracle is done using them, they should just “disappear.” The Large pool is not mandatory when using shared server connections, but it is highly recommended. If you do not have a Large pool and use a shared server connection, the allocations come out of the Shared pool as they always did in Oracle 7.3 and before. This will definitely lead to degraded performance over some period of time and should be avoided. The Large pool will default to some size if the parameter DBWR_IO_SLAVES or PARALLEL_MAX_ SERVERS is set to some positive value. It is recommended that you set the size of the Large pool manually if you are using a feature that uses it. The default mechanism is typically not the appropriate value for your situation. Java Pool The Java pool was added in version 8.1.5 of Oracle to support running Java in the database. If you code a stored procedure in Java, Oracle will make use of this chunk of memory when processing that code. The parameter JAVA_POOL_SIZE is used to fix the amount of memory allocated to the Java pool for all session-specific Java code and data. The Java pool is used in different ways, depending on the mode in which the Oracle server is running. In dedicated server mode, the Java pool includes the shared part of each Java class, which is actually used per session. These are basically the read-only parts (execution vectors, methods, etc.) and are about 4KB to 8KB per class. Thus, in dedicated server mode (which will most likely be the case for applications using purely Java stored procedures), the total memory required for the Java pool is quite modest and can be determined based on the number of Java classes you will be using. It should be noted that none of the per-session state is stored in the SGA in dedicated server mode, as this information is stored in the UGA and, as you will recall, the UGA is included in the PGA in dedicated server mode.
152 CHAPTER 4 ■ MEMORY STRUCTURES When connecting to Oracle using a shared server connection, the Java pool includes both of the following: • The shared part of each Java class. • Some of the UGA used for per-session state of each session, which is allocated from the JAVA_POOL within the SGA. The remainder of the UGA will be located as normal in the Shared pool, or if the Large pool is configured, it will be allocated there instead. As the total size of the Java pool is fixed in Oracle9i and before, application developers will need to estimate the total requirement of their applications and multiply this estimate by the number of concurrent sessions they need to support. This number will dictate the overall size of the Java pool. Each Java UGA will grow or shrink as needed, but bear in mind that the pool must be sized such that all UGAs combined must be able to fit in it at the same time. In Oracle 10g and above, this parameter may be modified, and the Java pool may grow and shrink over time without the database being restarted. Streams Pool The Streams pool is a new SGA structure starting in Oracle 10g. Streams itself is a new database feature as of Oracle9i Release 2 and above. It was designed as a data sharing/replication tool and is Oracle’s stated direction going forward for data replication. ■Note The statement that Streams “is Oracle’s stated direction going forward for data replication” should not be interpreted as meaning that Advanced Replication, Oracle’s now legacy replication feature, is going away anytime soon. Rather, Advanced Replication will continue to be supported in future releases. To learn more about Streams itself, see the Streams Concepts Guide available on http://otn.oracle.com in the Documentation section. The Streams pool (or up to 10 percent of the Shared pool if no Streams pool is configured) is used to buffer queue messages used by the Streams process as it is moving/copying data from one database to another. Instead of using permanent disk-based queues, with the attendant overhead associated with them, Streams uses in-memory queues. If these queues fill up, they will spill over to disk eventually. If the Oracle instance with the memory queue fails for some reason, due to an instance failure (software crash), power failure, or whatever, these in-memory queues are rebuilt from the redo logs. So, the Streams pool will only be important in systems using the Streams database feature. In those environments, it should be set in order to avoid “stealing” 10 percent of the Shared pool for this feature. Automatic SGA Memory Management Just as there are two ways to manage PGA memory, there are two ways to manage SGA memory starting in Oracle 10g: manually, by setting all of the necessary pool and cache parameters:
- Page 146 and 147: CHAPTER 3 ■ FILES 101 So, at the
- Page 148 and 149: CHAPTER 3 ■ FILES 103 Password Fi
- Page 150 and 151: CHAPTER 3 ■ FILES 105 USER is "SY
- Page 152 and 153: CHAPTER 3 ■ FILES 107 Flashback L
- Page 154 and 155: CHAPTER 3 ■ FILES 109 of the requ
- Page 156 and 157: CHAPTER 3 ■ FILES 111 IMPDP, howe
- Page 158 and 159: CHAPTER 3 ■ FILES 113 tkyte@ORA10
- Page 160 and 161: CHAPTER 4 ■ ■ ■ Memory Struct
- Page 162 and 163: CHAPTER 4 ■ MEMORY STRUCTURES 117
- Page 164 and 165: CHAPTER 4 ■ MEMORY STRUCTURES 119
- Page 166 and 167: CHAPTER 4 ■ MEMORY STRUCTURES 121
- Page 168 and 169: CHAPTER 4 ■ MEMORY STRUCTURES 123
- Page 170 and 171: CHAPTER 4 ■ MEMORY STRUCTURES 125
- Page 172 and 173: CHAPTER 4 ■ MEMORY STRUCTURES 127
- Page 174 and 175: CHAPTER 4 ■ MEMORY STRUCTURES 129
- Page 176 and 177: CHAPTER 4 ■ MEMORY STRUCTURES 131
- Page 178 and 179: CHAPTER 4 ■ MEMORY STRUCTURES 133
- Page 180 and 181: CHAPTER 4 ■ MEMORY STRUCTURES 135
- Page 182 and 183: CHAPTER 4 ■ MEMORY STRUCTURES 137
- Page 184 and 185: CHAPTER 4 ■ MEMORY STRUCTURES 139
- Page 186 and 187: CHAPTER 4 ■ MEMORY STRUCTURES 141
- Page 188 and 189: CHAPTER 4 ■ MEMORY STRUCTURES 143
- Page 190 and 191: CHAPTER 4 ■ MEMORY STRUCTURES 145
- Page 192 and 193: CHAPTER 4 ■ MEMORY STRUCTURES 147
- Page 194 and 195: CHAPTER 4 ■ MEMORY STRUCTURES 149
- Page 198 and 199: CHAPTER 4 ■ MEMORY STRUCTURES 153
- Page 200 and 201: CHAPTER 5 ■ ■ ■ Oracle Proces
- Page 202 and 203: CHAPTER 5 ■ ORACLE PROCESSES 157
- Page 204 and 205: CHAPTER 5 ■ ORACLE PROCESSES 159
- Page 206 and 207: CHAPTER 5 ■ ORACLE PROCESSES 161
- Page 208 and 209: CHAPTER 5 ■ ORACLE PROCESSES 163
- Page 210 and 211: CHAPTER 5 ■ ORACLE PROCESSES 165
- Page 212 and 213: CHAPTER 5 ■ ORACLE PROCESSES 167
- Page 214 and 215: CHAPTER 5 ■ ORACLE PROCESSES 169
- Page 216 and 217: CHAPTER 5 ■ ORACLE PROCESSES 171
- Page 218 and 219: CHAPTER 5 ■ ORACLE PROCESSES 173
- Page 220 and 221: CHAPTER 5 ■ ORACLE PROCESSES 175
- Page 222 and 223: CHAPTER 5 ■ ORACLE PROCESSES 177
- Page 224 and 225: CHAPTER 5 ■ ORACLE PROCESSES 179
- Page 226 and 227: CHAPTER 5 ■ ORACLE PROCESSES 181
- Page 228 and 229: CHAPTER 6 ■ ■ ■ Locking and L
- Page 230 and 231: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 232 and 233: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 234 and 235: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 236 and 237: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 238 and 239: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 240 and 241: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 242 and 243: CHAPTER 6 ■ LOCKING AND LATCHING
- Page 244 and 245: CHAPTER 6 ■ LOCKING AND LATCHING
CHAPTER 4 ■ MEMORY STRUCTURES 151<br />
The Large pool is used specifically by<br />
• Shared server connections, to allocate the UGA region in the SGA<br />
• Parallel execution of statements, to allow for the allocation of interprocess message<br />
buffers, which are used to coordinate the parallel query servers<br />
• Backup for RMAN disk I/O buffers in some cases<br />
As you can see, none of these memory allocations should be managed in an LRU buffer<br />
pool designed to manage small chunks of memory. With shared server connection memory,<br />
for example, once a session logs out, this memory is never going to be reused, so it should be<br />
immediately returned to the pool. Also, shared server UGA memory allocation tends to be<br />
“large.” If you review the earlier examples with the SORT_AREA_RETAINED_SIZE or PGA_<br />
AGGREGATE_TARGET, the UGA can grow very large <strong>and</strong> is definitely bigger than 4KB chunks.<br />
Putting MTS memory into the Shared pool causes it to fragment into odd-sized pieces of<br />
memory <strong>and</strong>, furthermore, you will find that large pieces of memory that will never be reused<br />
will age out memory that could be reused. This forces the database to do more work to rebuild<br />
that memory structure later.<br />
The same is true for parallel query message buffers, since they are not LRU manageable.<br />
They are allocated <strong>and</strong> cannot be freed until they are done being used. Once they have delivered<br />
their message, they are no longer needed <strong>and</strong> should be released immediately. With<br />
backup buffers, this applies to an even greater extent—they are large, <strong>and</strong> once <strong>Oracle</strong> is<br />
done using them, they should just “disappear.”<br />
The Large pool is not m<strong>and</strong>atory when using shared server connections, but it is highly<br />
recommended. If you do not have a Large pool <strong>and</strong> use a shared server connection, the<br />
allocations come out of the Shared pool as they always did in <strong>Oracle</strong> 7.3 <strong>and</strong> before. This will<br />
definitely lead to degraded performance over some period of time <strong>and</strong> should be avoided.<br />
The Large pool will default to some size if the parameter DBWR_IO_SLAVES or PARALLEL_MAX_<br />
SERVERS is set to some positive value. It is recommended that you set the size of the Large pool<br />
manually if you are using a feature that uses it. The default mechanism is typically not the<br />
appropriate value for your situation.<br />
Java Pool<br />
The Java pool was added in version 8.1.5 of <strong>Oracle</strong> to support running Java in the database.<br />
If you code a stored procedure in Java, <strong>Oracle</strong> will make use of this chunk of memory when<br />
processing that code. The parameter JAVA_POOL_SIZE is used to fix the amount of memory<br />
allocated to the Java pool for all session-specific Java code <strong>and</strong> data.<br />
The Java pool is used in different ways, depending on the mode in which the <strong>Oracle</strong> server<br />
is running. In dedicated server mode, the Java pool includes the shared part of each Java class,<br />
which is actually used per session. These are basically the read-only parts (execution vectors,<br />
methods, etc.) <strong>and</strong> are about 4KB to 8KB per class.<br />
Thus, in dedicated server mode (which will most likely be the case for applications using<br />
purely Java stored procedures), the total memory required for the Java pool is quite modest<br />
<strong>and</strong> can be determined based on the number of Java classes you will be using. It should be<br />
noted that none of the per-session state is stored in the SGA in dedicated server mode, as this<br />
information is stored in the UGA <strong>and</strong>, as you will recall, the UGA is included in the PGA in<br />
dedicated server mode.