05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

116<br />

CHAPTER 4 ■ MEMORY STRUCTURES<br />

at the system statistics, you’ll find the UGA reported in the PGA in dedicated server mode (the<br />

PGA will be greater than or equal to the UGA memory used; the PGA memory size will include<br />

the UGA size as well).<br />

So, the PGA contains process memory <strong>and</strong> may include the UGA. The other areas of PGA<br />

memory are generally used for in-memory sorting, bitmap merging, <strong>and</strong> hashing. It would be<br />

safe to say that, besides the UGA memory, these are the largest contributors by far to the PGA.<br />

Starting with <strong>Oracle</strong>9i Release 1 <strong>and</strong> above, there are two ways to manage this other non-<br />

UGA memory in the PGA:<br />

• Manual PGA memory management, where you tell <strong>Oracle</strong> how much memory is it<br />

allowed to use to sort <strong>and</strong> hash any time it needs to sort or hash in a specific process<br />

• Automatic PGA memory management, where you tell <strong>Oracle</strong> how much memory it<br />

should attempt to use systemwide<br />

The manner in which memory is allocated <strong>and</strong> used differs greatly in each case <strong>and</strong>, as<br />

such, we’ll discuss each in turn. It should be noted that in <strong>Oracle</strong>9i, when using a shared<br />

server connection, you can only use manual PGA memory management. This restriction was<br />

lifted with <strong>Oracle</strong> 10g Release 1 (<strong>and</strong> above). In that release, you can use either automatic or<br />

manual PGA memory management with shared server connections.<br />

PGA memory management is controlled by the database initialization parameter<br />

WORKAREA_SIZE_POLICY <strong>and</strong> may be altered at the session level. This initialization parameter<br />

defaults to AUTO, for automatic PGA memory management when possible in <strong>Oracle</strong>9i Release 2<br />

<strong>and</strong> above. In <strong>Oracle</strong>9i Release 1, the default setting was MANUAL.<br />

In the sections that follow, we’ll take a look at each approach.<br />

Manual PGA Memory Management<br />

In manual PGA memory management, the parameters that will have the largest impact on the<br />

size of your PGA, outside of the memory allocated by your session for PL/SQL tables <strong>and</strong> other<br />

variables, will be as follows:<br />

• SORT_AREA_SIZE: The total amount of RAM that will be used to sort information before<br />

swapping out to disk.<br />

• SORT_AREA_RETAINED_SIZE: The amount of memory that will be used to hold sorted<br />

data after the sort is complete. That is, if SORT_AREA_SIZE was 512KB <strong>and</strong> SORT_AREA_<br />

RETAINED_SIZE was 256KB, then your server process would use up to 512KB of memory<br />

to sort data during the initial processing of the query. When the sort was complete, the<br />

sorting area would be “shrunk” down to 256KB, <strong>and</strong> any sorted data that did not fit in<br />

that 256KB would be written out to the temporary tablespace.<br />

• HASH_AREA_SIZE: The amount of memory your server process would use to store hash<br />

tables in memory. These structures are used during a hash join, typically when joining<br />

a large set with another set. The smaller of the two sets would be hashed into memory<br />

<strong>and</strong> anything that didn’t fit in the hash area region of memory would be stored in the<br />

temporary tablespace by the join key.<br />

These parameters control the amount of space <strong>Oracle</strong> will use to sort or hash data before<br />

writing (swapping) it to disk, <strong>and</strong> how much of that memory segment will be retained after the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!