Dba Tuning
Dba Tuning
TUNING THE LIBRARY CACHE:-(hit ratio should be at least 85%, reload percent should be < 2%, if not,
increase SHARED_POOL_SIZE and parameter OPEN_CURSORS (in init.ora))
SELECT SUM (pinhits) / SUM (pins) "Hit Ratio",
SUM (reloads) / SUM (pins) "Reload percent"
FROM v$librarycache
WHERE namespace IN ('SQL AREA', 'TABLE/PROCEDURE', 'BODY', 'TRIGGER');
TUNING BUFFER CACHE HIT RATIO:-(should n't be <90%,if not increase DB_CACHE_SIZE)
SELECT 100 * (1 - (v3.VALUE / (v1.VALUE + v2.VALUE))) "Cache Hit Ratio [%]"
FROM v$sysstat v1, v$sysstat v2, v$sysstat v3
WHERE v1.NAME = 'db block gets'
AND v2.NAME = 'consistent gets'
AND v3.NAME = 'physical reads'
IDENTIFYING FREE LIST CONTENTION:-(<1%, if not To reduce contention for a table’s free list the
table must be recreated with a larger value in the FREELISTS storage parameter.)
select round( (sum(decode(w.class,'free list',count,0))
/ (sum(decode(name,'db block gets', value, 0))
+ sum(decode(name,'consistent gets', value, 0)))) * 100,2)
from v$waitstat w, v$sysstat;
If this returns a large number of rows then increase the number of ‘executions’ required. If it returns no
rows then perhaps decrease the number of executions required.
If there is SQL that is being repeatedly reparsed then consider increasing the value of SHARED_POOL_SIZE.
Excessively fragmented tables or indexes can adversely affect performance. Use the following SQL to
identify those database objects that have over 10 extents allocated:
select * from dba_segments where extents > 10;
In general, if a table or index has more than 10 extents then rebuild it to fit into one extent.
A table can only be rebuilt by exporting and then importing it. The database will be unavailable for use by
applications during this time. The steps to accomplish this are:
1. Export the table with COMPRESS=Y
2. Drop the table
3. Import the table.
An index can be rebuilt without preventing others from still using it. Firstly change the storage parameters
to make the ‘next’ storage parameter larger (perhaps double it). The initial storage value cannot be
changed. Then rebuild the index.
REBUILDING INDEXES:-
Periodically, and typically after large deletes or inserts, it is worth rebuilding indexes. The SQL for this is:
Alter index <index_name> rebuild;
Alternatively, the following performs the same, but avoids writing to the redo logs and thus speeds up the
index rebuild:
Alter index <index_name> rebuild unrecoverable;
Note: If performing this under Oracle 7.3 then be sure to specify the destination tablespace, ie:
Alter index <index_name> rebuild tablespace <tablespace>;
To identify contention for rollback segments first find out the number of times that processes had to wait for
the rollback segment header and blocks. The V$WAITSTAT view contains this information:
If the number of waits for any class of waits is greater than 1% of the total number of logical reads then
add more rollback segments.
The following query gives the percentage of times that a request for data resulted in a wait for a rollback
segment:
Rollback segments should be isolated as much as possible by placing them in their own tablespace,
preferably on a separate disk from other active tablespaces. The OPTIMAL parameter is used to cause
rollback segments to shrink back to an optimal size after they have dynamically extended.
The V$ROLLSTAT table can help in determining proper sizing of rollback segments:
If you do not need the Oracle HTTP Server (Apache) then ensure that the service
'OracleOraHome90HTTPServer' is not set to automatically start.
http://www.cryer.co.uk/brian/oracle/tuning.htm