Transcript Document
Performance Tuning: Summary
Copyright © 2006, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to do
the following:
• List best practices identified throughout the
course
• Summarize the performance tuning methodology
15-2
Copyright © 2006, Oracle. All rights reserved.
Necessary Initialization Parameters with
Little Performance Impact
Parameter
Description
DB_NAME
Name of the database. This should match the
ORACLE_SID environment variable.
DB_DOMAIN
Location of the database in Internet dot
notation
OPEN_CURSORS
Limit on the maximum number of cursors for
each session. The setting is applicationdependent; 500 is recommended.
CONTROL_FILES
Set to contain at least two files on different
disk drives to prevent failures from control file
loss
DB_FILES
Set to the maximum number of files that can
be assigned to the database
STATISTICS_LEVEL
Set to TYPICAL
15-3
Copyright © 2006, Oracle. All rights reserved.
Important Initialization Parameters
with Performance Impact
Parameter
Description
COMPATIBLE
To take advantage of the latest
improvements of a new release
DB_BLOCK_SIZE
8192 for OLTP and higher for DSS
SGA_TARGET
Automatically sized SGA components
PGA_AGGREGATE_TARGET
Automatic PGA management
PROCESSES
Maximum number of processes that can
be started by that instance
SESSIONS
To be used essentially with shared
server
UNDO_MANAGEMENT
AUTO mode recommended
UNDO_TABLESPACE
Undo tablespace to be used by instance
15-4
Copyright © 2006, Oracle. All rights reserved.
Sizing Memory Initially
As an initial guess for memory allocation:
• Leave 20% of available memory to other
applications.
• Leave 80% of memory to the Oracle instance.
• For OLTP:
SGA_TARGET=(total_mem*80%)*80%
PGA_AGGREGATE_TARGET=(total_mem*80%)*20%
•
For DSS:
SGA_TARGET=(total_mem*80%)*50%
PGA_AGGREGATE_TARGET=(total_mem*80%)*50%
15-6
Copyright © 2006, Oracle. All rights reserved.
Database High Availability: Best Practices
•
•
•
•
•
•
•
•
•
•
•
•
15-7
•
•
Multiplex redo logs.
Use resumable space allocation. •
Create at least two control files. •
Enable Flashback Database.
Use SPFILE.
Enable block checking.
Use auto-tune checkpointing.
Log checkpoints to the alert log.
Use database resource manager.
Use Automatic Undo Management.
Use Automatic Segment Space Management.
Use locally managed tablespaces.
Use locally managed temporary tablespaces.
Enable ARCHIVELOG mode and use a flash recovery area.
Set time long enough for CONTROL_FILE_RECORD_KEEP_TIME.
Designate a default permanent tablespace other than SYSTEM and
SYSAUX.
Copyright © 2006, Oracle. All rights reserved.
Undo Tablespace: Best Practices
•
•
Use Automatic Undo Management.
UNDO_RETENTION:
– Oracle Database 10g Release 1: Set it to your
flashback requirement.
– Oracle Database 10g Release 2: Do not set it.
•
Undo tablespace size:
– Initial size: Small with AUTOEXTEND enabled
– Steady state: Fix size using the Undo Advisor and
add a 20% safe margin.
15-8
Copyright © 2006, Oracle. All rights reserved.
Temporary Tablespace: Best Practices
Locally managed temporary tablespaces use a uniform
extent. Extent size should be:
• 1 MB to 10 MB extent size:
– For DSS, OLAP applications involving huge work
areas
– Large temporary LOBs are predominant.
•
64 KB or multiple less than 1 MB:
– Small global temporary tables are predominant.
– OLTP
Temporary tablespace group increases addressability
from TB to PB.
15-10
Copyright © 2006, Oracle. All rights reserved.
General Tablespace: Best Practices
•
•
•
•
•
•
15-12
Use locally managed tablespaces with autoallocate extents policy.
Use Automatic Segment Space Management
(ASSM).
Use online segment shrink to eliminate internal
fragmentation.
Periodically review the results of the Automatic
Segment Advisor.
Monitor tablespace space usage using servergenerated alerts.
Size of extents matter more than the number of
extents in the segments.
Copyright © 2006, Oracle. All rights reserved.
Internal Fragmentation Considerations
•
Watch for:
– Bad choices of PCTFREE and PCTUSED for heap
segments
– Bad choices of PCTVERSION and RETENTION for
LOB segments
– Low density of data in segment
– Direct loads followed by deletes (no inserts)
– Indexes on tables with random updates and deletes
with no further inserts
•
Remedy:
– Online segment shrink
– Online redefinition
– MOVE operations
15-13
Copyright © 2006, Oracle. All rights reserved.
Block Size: Advantages and
Disadvantages
Block Size
Smaller
Advantages
Small rows with lots of
random access
Disadvantages
Relatively high overhead
(block header)
Reduce block contention For large rows (chaining)
(OLTP)
Larger
15-15
Lower overhead: more
room for data
Waste cache space with
random access of small
rows
Good for sequential
access
Index leaf block
contention (OLTP)
Copyright © 2006, Oracle. All rights reserved.
Sizing Redo Log Files
•
•
•
•
•
15-16
Size of redo log files can influence performance.
Larger redo log files provide better performance.
Generally, redo log files should range between
100 MB and a few gigabytes.
Switch redo log file at most once every twenty
minutes.
Use the Redo Logfile Size Advisor to correctly size
your redo logs.
Copyright © 2006, Oracle. All rights reserved.
Automatic Statistics Gathering
•
STATISTICS_LEVEL = TYPICAL | ALL
•
Statistics are gathered by the predefined
GATHER_STATS_JOB job.
•
This job implicitly determines the following:
– Database objects with missing or stale statistics
– Appropriate sampling percentage necessary to
gather good statistics on those objects
– Appropriate columns that require histograms and
the size of those histograms
– Degree of parallelism for statistics gathering
– Prioritization of objects on which to collect
statistics
15-17
Copyright © 2006, Oracle. All rights reserved.
Automatic Statistics Collection:
Considerations
•
You should still manually gather statistics in the
following cases:
–
–
–
–
•
After bulk operations
When using external tables
To collect system statistics
To collect statistics on fixed objects
Prevent automatic gathering for volatile tables:
– Lock with statistics for representative values
– Lock without statistics implies dynamic sampling.
15-18
Copyright © 2006, Oracle. All rights reserved.
Commonly Observed Wait Events
Wait Event
Area
buffer busy waits
Buffer cache,
DBWR
Depends on buffer type. V$SESSION (block)
PK index and seq.
while issue is occurring
free buffer waits
Buffer cache,
DBWR, I/O
Slow DBWR
Write time using OS
stats. Buffer cache stats
db file scattered
read, db file
sequential read
I/O,
SQL Tuning
Poorly tuned SQL,
Slow I/O system
V$SQLAREA disk reads.
V$FILESTAT read time
Enqueue waits
(enq:)
Locks
Depends on enq type
V$ENQUEUE_STAT
Library cache
waits
Latches
SQL parsing/sharing
V$SQLAREA parse calls,
child cursors
log buffer space
Log buffer I/O
Small buffer, slow I/O
V$SYSSTAT redo buffer
allocation retries, disk
Log file sync
Over-commit,
I/O
Slow I/O, un-batched
commits
commits + rollbacks
from V$SYSSTAT, Disks.
15-19
Possible cause
Copyright © 2006, Oracle. All rights reserved.
Examine
Additional Statistics
Statistic name
Description
Recommended action
Redo Log Space
Requests
How many times a
server process had to
wait for space in the
online redo log
Checkpoints, DBWR,
or archiver activity
should be tuned,
larger log files
Consistent changes
How many rollbacks
done for consistent
read purposes
Use automatic undo,
tune the workload
Consistent gets
How many blocks are
read in Consistent
Read mode
Use automatic undo,
tune the workload
Table Fetch by
Continued Row
Migrated or chained
rows
Reorganize
15-20
Copyright © 2006, Oracle. All rights reserved.
Top 10 Mistakes Found in Oracle Systems
1. Bad connection management
2. Bad use of cursors and shared pool
3. Bad SQL
4. Use of nonstandard initialization parameters
5. Getting database I/O wrong
6. Redo log setup problems
7. Serialization of data blocks in the buffer cache
8. Long full-table scans
9. High amount of recursive SQL
10. Deployment and migration errors
15-21
Copyright © 2006, Oracle. All rights reserved.
Summary
In this lesson, you should have learned how to:
• Create your initial database following the best
practices identified throughout the course
• Summarize the performance tuning methodology
15-23
Copyright © 2006, Oracle. All rights reserved.