|
 |
|
Oracle dynamic memory reconfiguration
Oracle Tips by Burleson Consulting
February 25, 2015
|
For complete automated scripts and monitoring for
Oracle dynamic memory management, see
my book "Oracle
Tuning: The Definitive Reference".
In my opinion, the single
most important new feature
of Oracle9i is the ability
to dynamically modify
almost all of Oracle?s
performance parameters.
This lets an Oracle
professional dynamically
reconfigure the Oracle
instance while it's
running, whether in
reaction to a current
performance problem or in
anticipation of an
impending performance
demand.
Because everything
within the System Global
Area (SGA)?the RAM used by
an instance of Oracle?can
now be modified
dynamically, it's critical
for you to understand how
to monitor your Oracle
database. When you learn
to recognize trends and
patterns within your
system, you can
proactively reconfigure
the database in
anticipation of regular
resource needs.
With respect to ongoing
database tuning
activities, an Oracle
expert will generally look
at two areas: normally
scheduled reconfiguration
to support regularly
scheduled changes in
processing requirements,
and trend-based dynamic
reconfiguration made in
response to information
gained from STATSPACK.
Let?s examine how Oracle
supports both of these
activities.
Scheduled reconfiguration
Consider an Oracle
database that runs in
Online Transaction
Processing (OLTP) mode
during the day and in
Decision Support mode at
night. These two tasks
have very different
requirements for optimal
performance. For this type
of database, the Oracle
DBA can schedule a job to
reconfigure the Oracle
instance to the most
appropriate configuration
for the current type of
processing.
You?ll generally use one
of two tools for
scheduling a dynamic
reconfiguration. The most
common approach is to use
a UNIX cron job that
launches a shell script to
schedule a periodic
reconfiguration. You could
also use the Oracle
dbms_job utility.
Either of these tools will
allow you to schedule a
configuration change.
Below you?ll
find a UNIX script that
can be used to reconfigure
Oracle for decision
support processing. Note
that the script makes
changes to the
shared_pool,
db_cache_size, and
pga_aggregate_target
parameters to accommodate
data warehouse activity. A
similar script could then
be run in the morning to
change the database
configuration back to OLTP
mode.
Listing A:
#!/bin/ksh
# First, we must set the environment . . . .
ORACLE_SID=$1
export ORACLE_SID
ORACLE_HOME=`cat /etc/oratab|grep ^$ORACLE_SID:|cut -f2 -d':'`
#ORACLE_HOME=`cat /var/opt/oracle/oratab|grep ^$ORACLE_SID:|cut -f2 -d':'`
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
$ORACLE_HOME/bin/sqlplus ?s /nologin<<!
connect system/manager as sysdba;
alter system set db_cache_size=1500m;
alter system set shared_pool_size=500m;
alter system set pga_aggregate_target=4000m;
exit
!
Trend-based dynamic
reconfiguration
When performing
trend-based dynamic
reconfiguration, you?ll
collect historical data
about the Oracle database
and use this information
to proactively reconfigure
the database, perhaps by
using the dbms_job
package to fire ad-hoc
changes or by scheduling
regular reconfiguration
using one of the methods I
discussed. This is
analogous to just-in-time
manufacturing?where goods
appear on the
manufacturing floor at
just the time they are
needed in the assembly
process?in that an Oracle
DBA can anticipate
processing needs and
ensure that the SGA
resources are delivered in
time to accommodate
processing tasks.
You can use STATSPACK
to track signatures for
important metrics and
reveal patterns to predict
the resources that your
Oracle servers will need.
Metric signatures are
usually collected by hour
of the day and by day of
the week, making it easy
to discover these
patterns. For example,
consider the hour of the
day plot of the data
buffer hit ratio (BHR).
This BHR plot shows
a recurring shortage
of buffer blocks as
new programs start and
read data from disk.
Notice that the repeating
signature seems to
indicate a shortage of
data buffer blocks between
the hours of 2:00 and 3:00
A.M. and again between
8:00 and 9:00 P.M. Once
you know this, you can
schedule tasks to
reallocate RAM to the data
buffers during these time
periods to alleviate the
problem.
You can also plot the data
BHR by day of the week.
From the graph, you can
see problems on Monday and
Friday, indicating that
you need to increase the
db_cache_size for
those days to correct the
problem.

A daily BHR plot can
illustrate problems
over a longer cycle.
From the
10g documentation on memory usage we see that Oracle continues to recommend
using the buffer cache hit ratio in conjunction with other metrics, namely the
predictive ratio's displayed in the 10g buffer cache advisory:
"The buffer cache hit ratio can be used to verify the
physical I/O as predicted by V$DB_CACHE_ADVICE"
In a well-tuned production database, adding RAM to the data
buffers can make a difference in overall throughput, via a reduction in physical
disk reads, one of the most time-consuming operations in any Oracle database.
The Oracle AWR report contains a buffer advisory utility
that shows predictions of the marginal changes to physical disk reads with
changes to the buffer size:
Buffer Pool Advisory
-> Only rows with estimated physical reads >0 are displayed
-> ordered by Block Size, Buffers For Estimate
Size for Size Buffers for Est Physical Estimated
P Estimate (M) Factr Estimate Read Factor Physical Reads
--- ------------ ----- ---------- ------------- ------------------
D 4 .1 501 2.10 1,110,930
D 8 .2 1,002 1.84 970,631
D 12 .2 1,503 1.75 924,221
D 16 .3 2,004 1.62 857,294
D 20 .4 2,505 1.61 850,849
D 24 .5 3,006 1.59 837,223
D 28 .5 3,507 1.58 831,558
D 32 .6 4,008 1.57 829,083
D 36 .7 4,509 1.56 825,336
D 40 .8 5,010 1.56 823,195
D 44 .8 5,511 1.06 557,204
D 48 .9 6,012 1.01 534,992
D 52 1.0 6,513 1.00 527,967
D 56 1.1 7,014 0.78 411,218
D 60 1.2 7,515 0.35 186,842
D 64 1.2 8,016 0.28 148,305
D 68 1.3 8,517 0.26 134,969
D 72 1.4 9,018 0.23 123,283
D 76 1.5 9,519 0.23 121,878
D 80 1.5 10,020 0.23 120,317
-----------------------------------------------------
For a well-tuned database, the goal of setting the data buffer
size is to cache the "working set" of frequently referenced data blocks, the
point at which we see a marginal decline in the amount of RAM needed to reduce
disk reads:

However, there are some serious limitation to the Oracle
data buffer cache advisor:
-
Only one delta - Using only two observations for
logical reads and physical I/O are not enough data for a meaningful
prediction. The "current workload" assumption has a wide variance, and
the numbers for a one minute report will be quite different from a one
hour report.
-
Only two metrics - All of the advice from the
data buffer cache advisory is limited to logical I/O and physical I/O at the
system-wide level.
-
Assumption of optimization - The AWR data buffer
cache advisor (and possibly the related v$db_cache_advice utility),
only has two data points to consider and it assumes that the existing data
buffer size is optimal, the point at which the working set of
frequently-used data blocks are cached, and additions to the data buffer
result in marginally declining reductions in physical reads.
Trend-based information is
a gold mine for the Oracle
DBA because it can be used
to reveal previously
unseen performance trends
within an Oracle database.
In my next article, I?ll
take a closer look at the
metrics used by savvy
Oracle professionals to
determine how to
dynamically tune their
Oracle databases.
See these related notes on
dynamic memory
management:
 |
If you like Oracle tuning, you
might enjoy my book "Oracle
Tuning: The Definitive Reference", with 950 pages of tuning tips and
scripts.
You can buy it direct from the publisher for 30%-off and get instant
access to the code depot of Oracle tuning scripts. |
|