Transcript Document

TUNING

Office of the Accountant General (A&E) Andhra Pradesh Hyderabad VLC - AG(AE) AP

Tuning

When is tuning necessary?Only if you feel that application is not running

fast enough

What is to be tuned?Oracle databaseApplicationOperating systemNetwork

VLC - AG(AE) AP

Tuning Goals

To optimize the performance of

database

To make database available to users

without making them wait for resources

To perform maintenance operations

without interrupting users VLC - AG(AE) AP

Tuning Parameters

Response timeDatabase availabilityDatabase hit percentagesMemory utilization

VLC - AG(AE) AP

Tuning Steps

Tune the designTune the applicationTune memoryTune IOTune contentionTune operating system

VLC - AG(AE) AP

Tuning Considerations

Different for OLTP databasesDSS databasesHybrid databasesOur database Hybrid databaseData entry and Report generation done

simultaneously VLC - AG(AE) AP

Hybrid Databases

Number of rollback segments for data

entry

Some large rollback segments for

report generation

Balanced db_block_buffers and

log_buffers

Medium size for db_block_size

VLC - AG(AE) AP

Tuning Hybrid Databases

Tuning application is important in

hybrid databases

Indexing plays an important roleSchedule batch processing if it is

heavy on resources

Use less number of bind variables in

reports

Optimize queries using hints

VLC - AG(AE) AP

Views, Utilities and Tools Used For Tuning

Dynamic troubleshooting/performance

and dictionary views

V$XXXX dynamic troubleshooting and

performance views

DBA_XXX dictionary viewsUtlbstat.sql and utlestat.sqlAlert logs and traces

nitialization parameters VLC - AG(AE) AP

Tuning Statistics To Be Gathered

Library cache statisticsSystem statisticsWait event statisticsLatch statisticsRollback contention statisticsBuffer busy wait statisticsDictionary cache statisticsIO statistics per data file/table spacePeriod of measurement

VLC - AG(AE) AP

Alert Log Files

The lert log file consists of a

chronological log of messages and errors

Check the alert log file to:Detect internal errors and block corruption

errors

Monitor database operationsView the non-default initialization parametersRemove or trim the alert log file

regularly after checking VLC - AG(AE) AP

Background Processes Trace Files

The Oracle server dumps information

about errors detected by any background process in trace files

Oracle support uses these trace files

to diagnose and trouble shoot problems VLC - AG(AE) AP

User Trace Files

Server process tracing is enabled or disabled

at the session or instance level by:

The ALTER_SESSION commandThe SET_SQL_TRACE_IN_SESSION procedureThe initialization parameter SQL_TRACEA user trace file contain statistics for traced

SQL statements for that session

A user trace file is used for SQL tuningThe Oracle database creates user trace files

on per server process basis VLC - AG(AE) AP

Tuning Memory

The amount of memory occupied by

Oracle is called SGA

SGA containsDB Block BuffersRedo Log BuffersShared Pool o Library Cache o Data Dictionary Cache o UGA – Large Pool

VLC - AG(AE) AP

Tuning Memory

In hybrid databases like VLC, memory

plays an important role

Ideally DB_BLOCK_BUFFERS and

LOG_BUFFERS to be in 80-20 ratio

SHARED_POOL_SIZE also plays an

important parameter in tuning memory VLC - AG(AE) AP

Tuning Library Cache

Library Cache tuned If the pins to misses ratio is more than 1%If the get hit ratio of name space is less than

90%

V$ViewsV$LIBRARYCACHEV$SQLAREAV$SQLTEXTV$DB_OBJECT_CACHE

VLC - AG(AE) AP

Tuning Library Cache

To find hit ratio of library cacheSelect namespace, gethitratio from

v$librarycache

To find reloads of SQL statementsSelect sql_text, users_executing, executions,

loads from v$sqlarea

To find library cache reloadsSelect sum(pins) Executions, sum(reloads)

Misses, sum(reloads)/sum(pins) Hitratio from v$librarycache VLC - AG(AE) AP

Tuning Library Cache

Keep often used objectsAvoid parsing Avoid large anonymous PL/SQL Blocks Select sql_text from v$sqlarea where

command type=47;

Reserve un-fragmentable memory in

shared pool

SHARED_POOL_RESERVED_SIZESHARED_POOL_MIN_ALLOC

VLC - AG(AE) AP

Tuning Data Dictionary Cache

Keep the ratio of the getmisses to gets

less than 15%

Select parameter, gets, getmisses from

v$rowcache

Increase shared pool size if the above

ratio is more than 15% VLC - AG(AE) AP

Tuning DB Block Buffer Cache

DB hit ratio should always be more

than 90%

To find DB Cache hit ratioSelect 1-(p.value)/(d.value+c.value) from

v$sysstat p, v$sysstat d, v$sysstat c where p.name = ‘physical reads and d.name = ‘db block gets’ and c.name = ‘consistent gets’; VLC - AG(AE) AP

Tuning Buffer Cache

If DB hit ratio gets below 90% Increase buffer cache sizeUse multiple buffer poolsCache tablesBypass the buffer cache for sorting and

parallel reads VLC - AG(AE) AP

Tuning Buffer Pool

To use multiple pool buffers setDB_BLOCK_BUFFERSDB_BLOCK_LRU_LATCHESBUFFER_POOL_KEEPBUFFER_POOL_RECYCLETo enable table cachingAlter table with cache clauseUse cache hint in query

VLC - AG(AE) AP

Tuning Redo Log Buffer

Following parameters effect log bufferLOG_BUFFERLOG_CHECK_POINT_INTERVALLOG_CHECK_POINT_TIMEOUTCheck forRedo buffer space eventRedo buffer allocation retriesRedo log space requestsLogfile switch (check point incomplete)Logfile switch (archive needed)

VLC - AG(AE) AP

Tuning Check Point

Each checkpoint cause IO operationsFrequent checkpoints reduces runtime

performance

ParametersFAST_START_IO_TARGETLOG_CHECK_POINT_INTERVALLOG_CHECK_POINT_TIMEOUTDB_BLOCK_MAX_DIRTY_TARGETLOG_CHECK_POINT_TO_ALERT

VLC - AG(AE) AP

Tuning Large Pool

Used for oracle maintenance

operations

UGA in MTS modeParallel queryIO-server processTuning parametersLARGE_POOL_SIZEDBWR_IO_SLAVES

VLC - AG(AE) AP

Latches

Contention areas that the DBA can

tune:

Redo allocation latchRedo copy latchLRU latchLatch types Willing to wait o Gets, misses, sleeps – Immediate o Immediate gets and immediate waits

VLC - AG(AE) AP

LRU Latches

LRU latches regulate the least recently

used (LRU) lists used by the buffer cache

By default, the Oracle server set the

number of LRU latches to one-half the number of CPUs, with a minimum of one

Each latch controls a minimum of 50

buffers VLC - AG(AE) AP

LRU Latch Tuning Goals

Ensure there are sufficient number of

LRU latches for the data buffer cache so that contention between server processes is minimized

Balance the number of latches with

the number of CPUs

Set one DBWn process for each latch

VLC - AG(AE) AP

Resolving LRU Latch Contention

If the hit percentage for the LRU latch

is less than 99%

Increase the number of LRU latches by setting

the parameter DB_BLOCK_LRU_LATCHES

The maximum number of latches is the lower

of:

o Number of CPUs*2*3 o Number of buffers/50

VLC - AG(AE) AP

Free Lists

A free list for an object maintains a list

of blocks that are available for inserts

The number of free lists for an object

cannot be set dynamically

Single CPU systems do not benefit

greatly from multiple free lists

The tuning goal is to ensure that an

object has sufficient free lists to minimize contention VLC - AG(AE) AP

Resolving Free List Contention

Query the V$SESSION_WAIT viewIdentify the object and get free lists

for the segment from DBA_SEGMENTS

Re-create the object in question

VLC - AG(AE) AP

Tuning IO-contentions

Keep data files and log files on

separate disks

Stripe table dataReduce Disk IOEvaluate the use of RAW devicesTo know IO of filesSelect d.name, f.phyrds, f.phyrds from

v$datafile d, v$filestat where d.file# = f.file# VLC - AG(AE) AP

Oracle File Striping

Operating system stripingUse operating system striping software or

RAID

Decide on the right stripe sizeManual stripingUse the create table or alter table ALLOCATE

command

Is worth while with parallel query usage

VLC - AG(AE) AP

Tuning Data Files

Keep data files and log files on

separate disks to reduce IO contention

Specify the initialization parameter

DB_FILE_MULTIBLOCK_READ_COUNT

To determine the number of database blocks

the server reads at once

To influence the execution plan of the cost-

based optimizer VLC - AG(AE) AP

Tuning Log Files

Size redo log files to minimize the

contention

Have enough groups to prevent

waiting

Store redo log files on separate faster

devices

Dynamic viewsV$LOGV$LOGFILE

VLC - AG(AE) AP

Tuning Archive Log Files

Keep archive log files on separate IO

faster devices

Archive log operations parametersLOG_ARCHIVE_MAX_PROCESSESLOG_ARCHIVE_DESTDynamic viewsV$ARCHIVE_DESTV$ARCHIVE_LOGV$ARCHIVE_PROCESSES

VLC - AG(AE) AP

Tuning Rollback Segments

Transactions should never wait for

access to rollback segments

Rollback segments should not extend

during normal running

Users and utilities should try to use

less rollback

No transaction should ever run out of

rollback space

Readers should always see the read-

consistent images they need VLC - AG(AE) AP

Tuning Rollback Segments

The ratio of the sum of waits to the

sum of gets should be less than 1%

Select sum(gets) ‘gets’, sum(waits) ‘waits’,

sum(waits)*100/sum(gets) ‘ratio’ from v$rollstat;

If the ratio is more than 1% then

create more rollback segments

The number of waits for any class

should be less than 1% of the total number of requests VLC - AG(AE) AP

Sizing Transaction Rollback Data

Deletes are expensiveInserts use minimal rollback spaceUpdates use rollback space depending

on the number of columns

Index maintenance adds rollback

VLC - AG(AE) AP

Possible Problems

Transactions fails for lack of rollback

space

“Snapshot too old” error occurs if:The inserted transaction list in the block being

queried has been reused, and the SCN in the block is newer than the SCN at the start of the query

The transaction slot in the rollback segment

header has been reused

The undo data in the rollback segment has

been overlaid after a commit VLC - AG(AE) AP

Tablespace Usage

Reserve the SYSTEM tablespace usage for

data dictionary objects

Create locally managed tablespaces to avoid

space management issues

Split tables and indexes into separate

tablespaces

Create separate rollback tablespacesStore very large database objects in their

own tablespace

Create one or more temporary tablespaces

VLC - AG(AE) AP