|
|
Optimize your Oracle PGA RAM
Oracle Tips by Burleson Consulting |
Update: Oracle technology is constantly changing, so don't
miss my new notes on updates to Oracle PGA
behavior. Also see these important notes on over-riding the
Oracle PGA
defaults.
Determining the
PGA size is a critical part of Oracle RAM tuning. Each PGA RAM region is
allocated for every dedicated connection, and the size is determined as follows:
- OS Overhead - "Program Global Area (PGA):OS Overhead" - We reserve 2
meg for Windows and 1 meg for UNIX.
- Sort_area_size parameter value - " Program Global Area (PGA):
Sort_area_size" - This RAM is used for data row sorting inside the PGA.
- Hash_area_size parameter value - " Program Global Area (PGA)
:Hash_area_size " - This RAM defaults to 1.5 times sort_area_size and is
used for performing hash joins of Oracle tables.
The values for sort_area_size and hash_area_size are quickly shown with
the Oracle show parameters command:
SQL> show parameters area_size
NAME TYPE VALUE
------------------------------------ ----------- ---------
bitmap_merge_area_size integer 1048576
create_bitmap_area_size
integer 8388608
hash_area_size
integer 1048576
sort_area_size
integer 524288
workarea_size_policy
string MANUAL
A quick dictionary query (pga_size_each.sql) against the
v$parameter view will yield the correct value for each PGA RAM region size.
The data dictionary query output shows that the Oracle PGA will use 3.6
megabytes of RAM memory for each connected Oracle session.
PGA_SIZE
------------
3,621,440
If we now multiply the number of connected users by the PGA demands for each
user, we will know exactly how much RAM should be reserved for connected
sessions. Alternatively, we could issue an SQL statement to obtain the same
result. The script for such a statement is shown below.
A
script to compute total PGA RAM
This script reads both the sort_area_size and hash_area_size to compute
the total PGA region. The script will display a prompt for the high-water
mark of connected users and then computes the total PGA RAM to reserve for
dedicated Oracle connections. The MS-Windows PGA session incurs a 2 MB
overhead in this example.
set pages 999;
column pga_size format 999,999,999
accept hwm number prompt 'Enter the high-water mark of connected users: '
select
&hwm*(2048576+a.value+b.value) pga_size
from
v$parameter a,
v$parameter b
where
a.name = 'sort_area_size'
and
b.name = 'hash_area_size'
;
Running the script, we see that we are prompted for the high-water mark. We
will assume that the HWM of connected sessions to the Oracle database server
is 100. Oracle will do the math and display the amount of RAM to reserve for
Oracle connections.
SQL> @pga_size
Enter the high-water mark of connected users: 100
old 2: &hwm*(2048576+a.value+b.value) pga_size
new 2: 100*(2048576+a.value+b.value) pga_size
PGA_SIZE
------------
362,144,000
This and many related topics are covered in my upcoming new book
Oracle
Tuning: The Definitive Reference by Rampant TechPress. This book will be
printed in just a few weeks, and is available at this link: