Documente Academic
Documente Profesional
Documente Cultură
Brian Peasland
http://www.peasland.net
Abstract
Introduction
Each Oracle session needs memory set aside for it to perform certain work
operations. For instance, if the application requests a sorting operation by
using certain SQL statements, like GROUP BY or ORDER BY, the application’s
session can perform this sort in memory, provided enough memory has
been reserved for that sort operation. If there is not enough reserved
memory, then the sort operation is done in pieces using a temporary
holding area on disk in the TEMP tablespace.
To address this type of situation, Oracle created a way to let the instance
automatically manage the working areas of the database sessions. Oracle 9i
now has the ability to reserve a large chunk of working area space in
memory and to let the instance dynamically change the working area
allocations depending on the session’s operations. One session that needs
1MB of sort space and 4MB of hash area space would fit well into an
allocation as defined above. A second session that needs 4MB of sort space
and 1MB of hash area space would also fit well into a similar allocation since
Oracle 9i now has the capability to dynamically change these working area
allocations depending on the usage. Oracle 9i uses the PGA_AGGREGATE_TARGET
initialization parameter to define the total amount of PGA reserved memory.
Initial Setup
To begin using this new Oracle 9i feature, you need to set the
PGA_AGGREGATE_TARGET initialization parameter. This parameter can be set
without restarting the Oracle instance. As a guideline, Oracle recommends
initially setting this parameter to 16% of your server’s physical memory for
OLTP systems and 40% of your server’s physical memory for DSS systems.
Like any other memory configuration guidelines from Oracle Corp, this is
just a starting place. You will most likely want to tune this setting depending
on the usage of your system’s resources. My server has 1GB of physical
memory. Using the above guidelines, I will initially set my
PGA_AGGREGATE_TARGET initialization parameter. You can see an example of this
in Figure 1.
System altered.
With this parameter set, Oracle will now automatically perform dynamic
working area memory management.
Please note that the amount of memory set aside for the PGA_AGGREGATE_TARGET
is for all server processes, not for each server process. This parameter can
be set to zero to turn off dynamic working area memory management. The
acceptable range of values is between 10MB and 4096GB – 1.
Tuning PGA_AGGREGATE_TARGET
Oracle 9i gives us many different views to query to see how well our
dynamic working area memory management is performing. Oracle 9i has
added a few statistics to V$SYSTAT and V$SESSTAT.
NAME VALUE
---------------------------------------- ----------
workarea executions - optimal 510
workarea executions - onepass 1
workarea executions - multipass 4
Figure 2. – V$SYSTAT with 10MB PGA Target
Oracle 9i includes a new view called V$PGASTAT. This view can give you
additional statistics on how well the dynamic working area memory
management is performing.
16 rows selected.
Figure 3. V$PGASTAT with 10MB PGA Target
Oracle 9.2 includes two additional rows of output to V$PGASTAT. They are over
allocation count and cache hit percentage. If Oracle determines that it cannot
honor the setting for PGA_AGGREGATE_TARGET, then it needs to allocate
additional memory. The number of times Oracle detects this condition since
instance startup is noted by the over allocation count statistic. Ideally, this
value should be zero. The cache hit percentage statistic shows a hit ratio on
the number of bytes where optimal executions were performed compared
the total number of bytes for all executions, optimal, one-pass, and multi-
pass. If all executions where optimal, then this statistic should be 100%.
10 rows selected.
Figure 4. – V$PGA_TARGET_ADVICE with 10MB PGA Target
I expect that I will still have some executions that will require reads and
writes to disk since the read/write estimate show in Figure4 is non-zero for a
80MB PGA target. After restarting the instance and running the simulated
load, I can see that this is true from the query in Figure 5.
NAME VALUE
---------------------------------------- ----------
workarea executions - optimal 511
workarea executions - onepass 4
workarea executions - multipass 0
Figure 5. – V$SYSTAT with 80MB PGA Target
We can see in Figure 6 that we have eliminated the over allocation count
statistic. The auto target statistic is very close to the target parameter. So
we are getting closer. But the cache hit percentage is still far away from
100% and there are a large number of extra bytes read and written. We will
look for advice for our next setting in Figure 7.
Conclusion
References