Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005
CHAPTER 4 ■ MEMORY STRUCTURES 123 • The memory for these areas is allocated on an “as needed basis.” If you set the sort area size to 1GB as we did, it does not mean you will allocate 1GB of RAM. It only means that you have given the Oracle process the permission to allocate that much memory for a sort/hash operation. Automatic PGA Memory Management Starting with Oracle9i Release 1, a new way to manage PGA memory was introduced that avoids using the SORT_AREA_SIZE, BITMAP_MERGE_AREA_SIZE, and HASH_AREA_SIZE parameters. It was introduced to attempt to address a few issues: • Ease of use: Much confusion surrounded how to set the proper *_AREA_SIZE parameters. There was also much confusion over how those parameters actually worked and how memory was allocated. • Manual allocation was a “one-size-fits-all” method: Typically as the number of users running similar applications against a database went up, the amount of memory used for sorting/hashing went up linearly as well. If 10 concurrent users with a sort area size of 1MB used 10MB of memory, 100 concurrent users would probably use 100MB, 1,000 would probably use 1000MB, and so on. Unless the DBA was sitting at the console continually adjusting the sort/hash area size settings, everyone would pretty much use the same values all day long. Consider the previous example, where you saw for yourself how the physical I/O to temp decreased as the amount of RAM we allowed ourselves to use went up. If you run that example for yourself, you will almost certainly see a decrease in response time as the amount of RAM available for sorting increases. Manual allocation fixes the amount of memory to be used for sorting at a more or less constant number, regardless of how much memory is actually available. Automatic memory management allows us to use the memory when it is available; it dynamically adjusts the amount of memory we use based on the workload. • Memory control: As a result of the previous point, it was hard, if not impossible, to keep the Oracle instance inside a “box” memory-wise. You could not control the amount of memory the instance was going to use, as you had no real control over the number of simultaneous sorts/hashes taking place. It was far too easy to use more real memory (actual physical free memory) than was available on the machine. Enter automatic PGA memory management. Here, you first simply set up and size the SGA. The SGA is a fixed-size piece of memory, so you can very accurately see how big it is, and that will be its total size (until and if you change that). You then tell Oracle, “This is how much memory you should try to limit yourself across all work areas—a new umbrella term for the sorting and hashing areas you use.” Now, you could in theory take a machine with 2GB of physical memory and allocate 768MB of memory to the SGA and 768MB of memory to the PGA, leaving 512MB of memory for the OS and other processes. I say “in theory” because it doesn’t work exactly that cleanly, but it’s close. Before I discuss why that is true, we’ll take a look at how to set up automatic PGA memory management and turn it on.
124 CHAPTER 4 ■ MEMORY STRUCTURES The process to set this up involves deciding on the proper values for two instance initialization parameters, namely • WORKAREA_SIZE_POLICY: This parameter may be set to either MANUAL, which will use the sort area and hash area size parameters to control the amount of memory allocated, or AUTO, in which case the amount of memory allocated will vary based on the current workload present in the database. The default and recommended value is AUTO. • PGA_AGGREGATE_TARGET: This parameter controls how much memory the instance should allocate, in total, for all work areas used to sort/hash data. Its default value varies by version and may be set by various tools such as the DBCA. In general, if you are using automatic PGA memory management, you should explicitly set this parameter. So, assuming that WORKAREA_SIZE_POLICY is set to AUTO, and PGA_AGGREGATE_TARGET has a nonzero value, you will be using the new automatic PGA memory management. You can “turn it on" in your session via the ALTER SESSION command or at the system level via the ALTER SESSION command. ■Note Bear in mind the previously discussed caveat that in Oracle9i, shared server connections will not use automatic memory management; rather, they will use the SORT_AREA_SIZE and HASH_AREA_SIZE parameters to decide how much RAM to allocate for various operations. In Oracle 10g and up, automatic PGA memory management is available to both connection types. It is important to properly set the SORT_AREA_SIZE and HASH_AREA_SIZE parameters when using shared server connections with Oracle9i. So, the entire goal of automatic PGA memory management is to maximize the use of RAM while at the same time not using more RAM than you want. Under manual memory management, this was virtually an impossible goal to achieve. If you set SORT_AREA_SIZE to 10MB, when one user was performing a sort operation that user would use up to 10MB for the sort work area. If 100 users were doing the same, they would use up to 1000MB of memory. If you had 500MB of free memory, the single user performing a sort by himself could have used much more memory, and the 100 users should have used much less. That is what automatic PGA memory management was designed to do. Under a light workload, memory usage could be maximized as the load increases on the system, and as more users perform sort or hash operations, the amount of memory allocated to them would decrease—to obtain the goal of using all available RAM, but not attempting to use more than physically exists. Determining How the Memory Is Allocated Questions that come up frequently are “How is this memory allocated?” and “What will be the amount of RAM used by my session?” These are hard questions to answer for the simple reason that the algorithms for serving out memory under the automatic scheme are not documented and can and will change from release to release. When using things that begin with “A”—for automatic—you lose a degree of control, as the underlying algorithms decide what to do and how to control things.
- Page 118 and 119: CHAPTER 3 ■ FILES 73 *.cluster_da
- Page 120 and 121: CHAPTER 3 ■ FILES 75 ops$tkyte@OR
- Page 122 and 123: CHAPTER 3 ■ FILES 77 • To maint
- Page 124 and 125: CHAPTER 3 ■ FILES 79 • Resource
- Page 126 and 127: CHAPTER 3 ■ FILES 81 3 l_dummy nu
- Page 128 and 129: CHAPTER 3 ■ FILES 83 Trace Files
- Page 130 and 131: CHAPTER 3 ■ FILES 85 _qerixAlloca
- Page 132 and 133: CHAPTER 3 ■ FILES 87 6 ( 7 TYPE O
- Page 134 and 135: CHAPTER 3 ■ FILES 89 A Brief Revi
- Page 136 and 137: CHAPTER 3 ■ FILES 91 Redundant Ar
- Page 138 and 139: CHAPTER 3 ■ FILES 93 (data from m
- Page 140 and 141: CHAPTER 3 ■ FILES 95 dictionary t
- Page 142 and 143: CHAPTER 3 ■ FILES 97 ■Note df i
- Page 144 and 145: CHAPTER 3 ■ FILES 99 “accidenta
- 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 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 196 and 197: CHAPTER 4 ■ MEMORY STRUCTURES 151
- 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
CHAPTER 4 ■ MEMORY STRUCTURES 123<br />
• The memory for these areas is allocated on an “as needed basis.” If you set the sort area<br />
size to 1GB as we did, it does not mean you will allocate 1GB of RAM. It only means that<br />
you have given the <strong>Oracle</strong> process the permission to allocate that much memory for a<br />
sort/hash operation.<br />
Automatic PGA Memory Management<br />
Starting with <strong>Oracle</strong>9i Release 1, a new way to manage PGA memory was introduced that<br />
avoids using the SORT_AREA_SIZE, BITMAP_MERGE_AREA_SIZE, <strong>and</strong> HASH_AREA_SIZE parameters.<br />
It was introduced to attempt to address a few issues:<br />
• Ease of use: Much confusion surrounded how to set the proper *_AREA_SIZE parameters.<br />
There was also much confusion over how those parameters actually worked <strong>and</strong> how<br />
memory was allocated.<br />
• Manual allocation was a “one-size-fits-all” method: Typically as the number of users<br />
running similar applications against a database went up, the amount of memory used<br />
for sorting/hashing went up linearly as well. If 10 concurrent users with a sort area size<br />
of 1MB used 10MB of memory, 100 concurrent users would probably use 100MB, 1,000<br />
would probably use 1000MB, <strong>and</strong> so on. Unless the DBA was sitting at the console continually<br />
adjusting the sort/hash area size settings, everyone would pretty much use the<br />
same values all day long. Consider the previous example, where you saw for yourself<br />
how the physical I/O to temp decreased as the amount of RAM we allowed ourselves<br />
to use went up. If you run that example for yourself, you will almost certainly see a<br />
decrease in response time as the amount of RAM available for sorting increases. Manual<br />
allocation fixes the amount of memory to be used for sorting at a more or less constant<br />
number, regardless of how much memory is actually available. Automatic memory<br />
management allows us to use the memory when it is available; it dynamically adjusts<br />
the amount of memory we use based on the workload.<br />
• Memory control: As a result of the previous point, it was hard, if not impossible, to keep<br />
the <strong>Oracle</strong> instance inside a “box” memory-wise. You could not control the amount of<br />
memory the instance was going to use, as you had no real control over the number of<br />
simultaneous sorts/hashes taking place. It was far too easy to use more real memory<br />
(actual physical free memory) than was available on the machine.<br />
Enter automatic PGA memory management. Here, you first simply set up <strong>and</strong> size the<br />
SGA. The SGA is a fixed-size piece of memory, so you can very accurately see how big it is, <strong>and</strong><br />
that will be its total size (until <strong>and</strong> if you change that). You then tell <strong>Oracle</strong>, “This is how much<br />
memory you should try to limit yourself across all work areas—a new umbrella term for the<br />
sorting <strong>and</strong> hashing areas you use.” Now, you could in theory take a machine with 2GB of<br />
physical memory <strong>and</strong> allocate 768MB of memory to the SGA <strong>and</strong> 768MB of memory to the<br />
PGA, leaving 512MB of memory for the OS <strong>and</strong> other processes. I say “in theory” because it<br />
doesn’t work exactly that cleanly, but it’s close. Before I discuss why that is true, we’ll take a<br />
look at how to set up automatic PGA memory management <strong>and</strong> turn it on.