less_02_performance-tuining_oracle1g
-
Upload
aryansharma -
Category
Documents
-
view
18 -
download
2
description
Transcript of less_02_performance-tuining_oracle1g
2Copyright © 2008, Oracle. All rights reserved.
Basic Tuning Tools
Copyright © 2008, Oracle. All rights reserved.2 - 2
Objectives
After completing this lesson, you should be able to do the following:• View the top wait events to determine the highest wait• View the time model to diagnose performance issues• Use dynamic performance views to view statistics and wait
events• Use Enterprise Manager Monitoring• Identify the key tuning components of the alert logs• Identify the key tuning components of user trace files
Copyright © 2008, Oracle. All rights reserved.2 - 3
Performance Tuning Diagnostics
Diagnostic tools gather and format the following types of performance data:• Cumulative statistics:
– Wait events with time information– Time model
• Metrics: Statistic rates • Sampled statistics: Active Session History
– Statistics by session– Statistics by SQL– Statistics by service– Other dimensions
Copyright © 2008, Oracle. All rights reserved.2 - 4
Performance Tuning Tools
Available tools:• Basic:
– Time model– Top wait events– Dynamic performance views and tables– Alert log– Trace files– Enterprise Manager pages
• Add-in: Statspack• Options:
– Diagnostics pack– Tuning pack
Copyright © 2008, Oracle. All rights reserved.2 - 5
Tuning Objectives
The objectives of tuning are:• Minimizing response time• Increasing throughput• Increasing load capabilities• Decreasing recovery time
Copyright © 2008, Oracle. All rights reserved.2 - 6
Top Wait Events
Copyright © 2008, Oracle. All rights reserved.2 - 7
DB Time
DB Time =
DB Wait Time +
DB CPU Time
Copyright © 2008, Oracle. All rights reserved.2 - 8
CPU and Wait Time Tuning Dimensions
Scalableapplication
Possiblyneeds SQL
tuning
Needsinstance/RAC
tuning
CPUtime
Waittime
No gain achievedby adding
CPUs/nodes
DB time = DB CPU time + DB wait time
Copyright © 2008, Oracle. All rights reserved.2 - 9
Time Model: Overview
• The time model is a set of statistics that give an overview of where time is spent inside the Oracle database.
• All statistics use the same dimension: time.• The statistics are accessible through:
– V$SYS_TIME_MODEL– V$SESS_TIME_MODEL
• DB time represents the totaltime spent in database calls.
• A tuning goal is to reduce DB time.• Using DB time, you can gauge the performance impact of
any entity of the database.
SQL
PLSQL Con
nectParse
Java
DB time
Copyright © 2008, Oracle. All rights reserved.2 - 10
Time Model Statistics Hierarchy
Failed parse (out of shared memory) elapsed time
DB timeDB CPUConnection management call elapsed time Sequence load elapsed time SQL execute elapsed time
Parse time elapsed Hard parse elapsed time
Hard parse (sharing criteria) elapsed time Hard parse (bind mismatch) elapsed time
Failed parse elapsed time
PL/SQL execution elapsed time Inbound PL/SQL RPC elapsed time PL/SQL compilation elapsed time Java execution elapsed time
Repeated bind elapsed time
Background elapsed time Background CPU time
RMAN CPU time (backup/restore)
Copyright © 2008, Oracle. All rights reserved.2 - 12
Time Model Example
Copyright © 2008, Oracle. All rights reserved.2 - 13
Dynamic Performance Views
Dynamic performance views provide access to information about changing states and conditions in the instance.
Session dataWait events
Memory allocationsRunning SQL
UNDO usageOpen cursors
Redo log usageAnd so on
Oracle instance
Copyright © 2008, Oracle. All rights reserved.2 - 14
Dynamic Performance Views:Usage Examples
SQL> SELECT sql_text, executions 2 FROM v$sqlstats 3 WHERE cpu_time > 200000;
SQL> SELECT * FROM v$session 2 WHERE machine = 'EDRSR9P1' and 3 logon_time > SYSDATE - 1;
SQL> SELECT sid, ctime 2 FROM v$lock WHERE block > 0;
a
b
c
Copyright © 2008, Oracle. All rights reserved.2 - 15
Dynamic Performance Views: Considerations
• These views are owned by SYS.• Different views are available at different times:
– The instance has been started.– The database is mounted.– The database is open.
• You can query V$FIXED_TABLE to see all the view names.• These views are often referred to as “v-dollar views.”• Read consistency is not guaranteed on these views because
the data is dynamic.
Copyright © 2008, Oracle. All rights reserved.2 - 16
Statistic Levels
STATISTICS_LEVEL
BASIC TYPICAL ALL
Recommendeddefault value
Additional statisticsfor manual
SQL diagnostics
Disable all self-tuningcapabilities
V$STATISTICS_LEVEL
Copyright © 2008, Oracle. All rights reserved.2 - 18
Statistics and Wait Events
StatisticsWait events
Reports
Dynamic performance
views
Copyright © 2008, Oracle. All rights reserved.2 - 19
System Statistic Classes
Cache
Debug
RAC
SQLRedo
User
Enqueue
OS
V$SYSSTAT
V$SESSTATV$STATNAME
Systemstatisticclasses
Copyright © 2008, Oracle. All rights reserved.2 - 20
Displaying Statistics
Statistics are collected for:• Sessions
– All sessions V$SESSTAT– Current session V$MYSTAT
• Services V$SERVICE_STATS• System V$SYSSTAT
Copyright © 2008, Oracle. All rights reserved.2 - 22
Displaying SGA Statistics
NAME BYTES RES-------------------------------- ---------- ---Fixed SGA Size 1303132 NoRedo Buffers 17780736 NoBuffer Cache Size 50331648 YesShared Pool Size 142606336 YesLarge Pool Size 4194304 YesJava Pool Size 12582912 YesStreams Pool Size 0 YesShared IO Pool Size 0 YesGranule Size 4194304 NoMaximum SGA Size 836976640 NoStartup overhead in Shared Pool 41943040 NoFree SGA Memory Available 608174080
SQL> SELECT * FROM V$SGAINFO;
Copyright © 2008, Oracle. All rights reserved.2 - 23
Wait Events
• A collection of wait events provides information about the sessions that had to wait or must wait for different reasons.
• These events are listed in the V$EVENT_NAME view, which has the following columns:
– EVENT#– NAME– PARAMETER1– PARAMETER2– PARAMETER3
Wait
Copyright © 2008, Oracle. All rights reserved.2 - 24
Using the V$EVENT_NAME View
NAME PARAMETER1 PARAMETER2 PARAMETER3
------------------------------- ---------- ---------- ----------
PL/SQL lock timer duration
alter system set mts_dispatcher waited
buffer busy waits file# block# id
library cache pin handle addr pin address 0*mode+name
log buffer space
log file switch (checkpoint incomplete)
transaction undo seg# wrap# count
...
961 rows selected.
SQL> SELECT name, parameter1, parameter2, parameter3 2 FROM v$event_name;
Copyright © 2008, Oracle. All rights reserved.2 - 25
Wait Classes
Scheduler
Cluster Configuration
Commit
Application
Administrative
Network User I/O
Concurrency
System I/O
Other
Idle
Backgroundprocesses I/O
Foregroundprocesses I/O
DBAcommands
Should berare
Inadequate database/instance configuration
Resource manager
RACresources
Userapplication
code
Inactivesessions
Networkmessaging
log file sync
Internal database resources
V$SESSION_WAIT_CLASS
V$SERVICE_WAIT_CLASS
V$SYSTEM_WAIT_CLASS
V$EVENT_NAME
Waitclasses
Copyright © 2008, Oracle. All rights reserved.2 - 26
Displaying Wait Event Statistics
• Wait event statistics levels:– System– Service– Session
• Wait event statistics columns vary by view.
V$SERVICE_EVENT
V$SYSTEM_EVENT
V$SESSION_EVENT
EVENT X X X
TOTAL_WAITS X X X
TOTAL TIMEOUTS X X X
TIME_WAITED X X X
AVERAGE_WAIT X X X
TIME_WAITED_MICRO X X X
EVENT_ID X X X
TOTAL_WAIT_FG X
TOTAL_TIMEOUTS_FG X
TIME_WAITED_FG X
AVERAGE_WAIT_FG X
TIME_WAITED_MICRO_FG X
SID X
SERVICE_NAME X
SERVICE_NAME_HASH X
WAIT_CLASS_ID X X
WAIT_CLASS# X X
WAIT_CLASS X X
Copyright © 2008, Oracle. All rights reserved.2 - 28
Commonly Observed Wait Events
Wait Event AreaBuffer busy waits Buffer cache, DBWR
Free buffer waits Buffer cache, DBWR, I/O
Db file scattered read, Db file sequential read
I/O, SQL Tuning
Enqueue waits (enq:) Locks
Library cache waits Latches
Log buffer space Log buffer I/O
Log file sync Over-commit, I/O
Copyright © 2008, Oracle. All rights reserved.2 - 29
Using the V$SESSION_WAIT View
SID SEQ# EVENT WAIT STATETIME
--- - -- ---- -------------------------------- -------1 1284 pmon timer 0 WAITING2 1697 rdbms ipc message 0 WAITING3 183 rdbms ipc message 0 WAITING4 4688 rdbms ipc message 0 WAITING5 114 smon timer 0 WAITING6 14 SQL*Net message from client -1 WAITED
SHORTTIME
SQL> SELECT sid, seq#, event, wait_time, state 2 FROM v$session_wait;
Copyright © 2008, Oracle. All rights reserved.2 - 31
Precision of System Statistics
• Views that include microsecond timings:– V$SESSION_WAIT, V$SYSTEM_EVENT,
V$SERVICE_EVENT, V$SESSION_EVENT (TIME_WAITED_MICRO column)
– V$SQL, V$SQLAREA (CPU_TIME, ELAPSED_TIME columns)
– V$LATCH, V$LATCH_PARENT, V$LATCH_CHILDREN (WAIT_TIME column)
– V$SQL_WORKAREA, V$SQL_WORKAREA_ACTIVE (ACTIVE_TIME column)
• Views that include millisecond timings:– V$ENQUEUE_STAT (CUM_WAIT_TIME column)
Copyright © 2008, Oracle. All rights reserved.2 - 32
Using Features of the Packs
• SQL traces• Statspack• System statistics• Wait model• Time model• OS statistics• Metrics• Service statistics• Histograms• Optimizer statistics• SQL statistics
Monitoring and tuningwith packs
Monitoring and tuning without packs
Database Configuration Management Pack• Database and Host Configuration• Deployments • Patch Database and View Patch Cache • Patch staging • Clone Database • Clone Oracle Home • Search configuration • Compare configuration • Policies
Database Diagnostics Pack• Automatic Workload Repository• Automatic Database Diagnostic Monitor (ADDM)• Active Session History (ASH)• Performance monitoring (database and host)• Event notifications: notification methods, rules, and schedules• Event history and metric history (database and host)• Blackouts• Dynamic metric baselines• Monitoring templates
Database Tuning Pack• SQL Access Advisor• SQL Tuning Advisor• Automatic SQL Tuning• SQL Tuning Sets• Automatic Plan Evolution of SQL Plan Management• SQL Monitoring• Reorganize objects
Copyright © 2008, Oracle. All rights reserved.2 - 34
Accessing the Database Home Page
https://host name:1158/em
Copyright © 2008, Oracle. All rights reserved.2 - 35
Enterprise Manager Performance Pages
Copyright © 2008, Oracle. All rights reserved.2 - 37
Viewing the Alert Log
Database Home page > Related Links region >Alert Log Contents
Copyright © 2008, Oracle. All rights reserved.2 - 38
Using Alert Log Information as an Aid in Tuning
The alert log file contains the following information that can be used to aid in tuning the database:• Time to perform archiving• Instance recovery start and complete times• Deadlock and timeout errors• Incomplete checkpoints• Checkpoint start and end times
Copyright © 2008, Oracle. All rights reserved.2 - 40
User Trace Files
• Server-process tracing can be enabled or disabled at the session or instance level.
• A user trace file contains statistics for traced SQL statements in that session.
• User trace files are created on a per server process basis.• User trace files can also be created by:
– Performing a BACKUP CONTROL FILE TO TRACE– Process errors
Copyright © 2008, Oracle. All rights reserved.2 - 41
Background Processes Trace Files
• The Oracle database server dumps information about errors detected by any background process into trace files.
• Oracle Support uses these trace files to diagnoseand troubleshoot.
• These files do not usually contain tuning information.
Copyright © 2008, Oracle. All rights reserved.2 - 42
Summary
In this lesson, you should have learned how to:• View the top wait events to determine highest wait• View the time model to diagnose performance issues• Use dynamic performance views to view statistics and wait
events• Use Enterprise Manager Monitoring• Identify the key tuning components of the alert logs• Identify the key tuning components of user trace files
Copyright © 2008, Oracle. All rights reserved.2 - 43
Practice 2 Overview:Using Basic Tools
This practice covers the following topics:• View the top waits events and the time model• Use the alert log information for tuning• View system statistics• View wait events