Mohan asks: I hear that the
spin_count parameter can help relieve latch contention (high latch wait values
in STATSPACK reports), but I would like to know how Oracle 9i and later versions
moved the spin_count parameter to a hidden _spin_count parameter. Why did
Oracle 9i depreciated the spin_count parameter? Is there any other
parameter to replace spin_count in oracle 9i and beyond?
Answer: The spin_count was
designed to allow the DBA to control the amount of time spent "spinning"
(waiting) for a serialization latch to be released and has a default value of
2,000. Since spin_count sets the number of spins a process will undergo
before trying to get a latch, if the CPU is not fully loaded, a high value may
be best; for a fully-loaded CPU, a smaller value for spin_count may help.
As you noted, spin_count is still
there, re-named to an undocumented parm _spin_count. While Oracle
does publish their reasons, MOSC Note:30832.1 says that spin_count is of
limited value:
?If a system is not tight on CPU resource
SPIN_COUNT can be left at higher values but anything above 2000 is unlikely
to be of any benefit.?.
Some DBA's will try to increase spin_count
in an attempt to reduce latch contention. This is a brute force approach
where we are increasing the probability of obtaining the latch by increasing the
number of requests for the latch. In most cases, this addresses the symptom of
the problem and not the original cause.
In my experience, you rarely need to adjust
your spin_count, but there are some systems where changing the now-undocumented
_spin_count can help to relieve latch contention.
Also,
Guy Harrison notes that spin_count can still be valuable as a tuning tool:
"Latches protect areas of Oracle shared
memory from concurrent access in roughly the same way that locks protect
data in tables. When a session wants a latch it will repeatedly attempt to
obtain the latch until reaching the value of "_spin_count" after
which it will sleep and a "latch free" wait will occur. Excessive latch
sleeps can create restrictions on throughput and response time.
The two most frequently encountered forms of latch contention in modern
Oracle (10g/11g) are:
- Library cache/shared pool latch
contention - This is usually caused when an application issues high
volumes of SQL which are non-sharable due to an absence of bind
variables. The CURSOR_SHARING parameter can often be used to alleviate
this form of contention.
- cache buffer chains contention - This is usually associated
with very high logical read rates and "hot" blocks within the database
(sometimes index blocks). After tuning SQL to reduce logical IO and
eliminate repetitive reads of the same information, partitioning is
often a possible solution.
If latch contention is causing serious
problems, and the system has some free CPU capacity, adjusting the value of
the undocumented parameter _spin_count may be effective in reducing
contention. As always, modifying undocumented parameters should be
approached with great caution. "
This script can display the value for
_spin_count:
COLUMN parameter FORMAT a37
COLUMN description FORMAT a30 WORD_WRAPPED
COLUMN "Session VALUE" FORMAT a10
COLUMN "Instance VALUE" FORMAT a10
SET LINES 100 PAGES 0