DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John...

45

Transcript of DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John...

Page 1: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.
Page 2: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

<Insert Picture Here>

DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John BeresniewiczOracle Corporation RMOUG

Feb 2008

Page 3: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a

commitment to deliver any material, code, or functionality, and should not be relied upon

in making purchasing decisions.The development, release, and timing of any

features or functionality described for Oracle’s products remains at the sole

discretion of Oracle.

Page 4: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Agenda

• Brief History of Oracle Performance Tuning Methods• DB Time: What is it?• DB Time: Data Sources• DB Time Method

Page 5: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Oracle Tuning Methods

• Prehistory• Debug code

• Dark Ages• Counters/Ratios

• BSTAT/ESTAT

• SQL*Trace

• Renaissance• Increased instrumentation inc. Wait Events

• Move from counters to timers

• STATSPACK

Page 6: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Oracle Tuning Methods

• More Recent Methods – Time-based methods• YAPP

• Instance tuning - instance statistics• Non intrusive• Always on

• Method R• Session tuning – sql trace based

• Tightly scoped• Must be highly selective

• Modern advances• DB Time Tuning

• Instrumentation improvements• ASH, AWR,ADDM

Page 7: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Why Do We Care About Time? Performance Is Always About Time

• Human time is critical to the enterprise

• System time includes human and IT resource time to accomplish business goals

• System performance affects business goals• “Time is money.”

• Performance improvement usually means doing things faster

• Method: find where system time is spent – reduce it!

Page 8: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The DB Time Method

• Uses combination of cumulative and sampled DB Time• ‘Always on’ data only

• Combines best of current methods• Low intrusion• Detailed data

• No scope necessary for collections• No requirement to reproduce problem• Works for concurrency problems such as locking

Page 9: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The DB Time Method

• Supports multiple scopes for diagnosis• Database• Instance• Session• Client id• Module/Action• SQL ID

• More inclusive, less intrusive

Page 10: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Database time (DB Time)

• Time spent in database calls by foreground sessions

• Includes CPU time, IO time and wait time

• Excludes idle wait time

• The lingua franca for Oracle performance analysis

Database time is total time spent by user processes either actively working or actively

waiting in a database call.

Page 11: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Single session with Database Black Box server

Browse

Books

Read Reviews

For One BookAdd to Cart Checkout

TIME = time spent in database

A Single Session

Page 12: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Active Session = Session currently spending time in a database call

Database Time (DB Time) = Total time session spent in all database calls

Average Activity of the Session (% Activity) = The ratio of time active to total wall clock time

Browse

Books

Read Reviews

For One BookAdd to Cart Checkout

TIME = time spent in database

Fundamental concepts

Page 13: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.
Page 14: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Active sessions

• Foreground sessions in a database call• Backgrounds are also interesting

• Either on CPU, waiting for IO, or waiting (not idle)

• V$ACTIVE_SESSION_HISTORY is a collection of timed regular samples of active session attributes

Active sessions are foreground sessions contributing to DB time in any given moment.

Page 15: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

= time spent in database

Multiple Sessions

TIME

User 1

User 2

User 3

User n

t

At time t we have 2 active sessions

DB Time = Sum of DB Time Over All Sessions

Avg. Active Sessions = Sum of Avg. Activity Over All Sessions

Page 16: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

= time spent in database

Browse

Books

Read Reviews

For One BookAdd to Cart Checkout

TIME

Avg. Active Sessions =Wall Clock (Elapsed) Time

Database Time

The Basic Relationship

Page 17: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

DB time

Page 18: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

System load and DB time

• More users• => More calls

• => DB time increases

• Larger transactions• => Longer calls

• => DB time increases

DB time increases as system load increases.

Page 19: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

System performance and DB time

• IO performance degrades • => IO time increases

• => DB time increases

• Application performance degrades• => Wait time increases

• => DB time increases

DB time increases as system performance degrades.

Page 20: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

System performance and DB time

Page 21: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Where to find DB time?

• V$SYS_TIME_MODEL• STAT_NAME = ‘DB time’• Accumulated value over entire instance

• V$WAITCLASSMETRIC_HISTORY• AVERAGE_WAITER_COUNT

• It is precisely Average Active Sessions

• V$SYSMETRIC_HISTORY • “Database Time Per Second”, “CPU Usage Per Sec” • Units are Centi-seconds per second• Value is 100 x Average Active Sessions

Page 22: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Where to find DB time?

• V$SQL• ELAPSED_TIME• Also wait class times

• V$ACTIVE_SESSION_HISTORY• Sample per second• Count = time

Page 23: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

timet0 t1

Estimating DB time with ASH

Active sessions

t = 1 sec

ASH sample count is value of active sessions function at sample times

DB Time

DB time is area under curve

Page 24: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Integral approximation using ASH

second) 1 (where

1*

*)(lim

)( time DB

1

0

10

t1

t0

t

ASHsamples

ttionsActiveSess

dttionsActiveSess

tsampletime

tsampletime

n

kk

t

Page 25: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

EM Top Activity page

• ASH-estimated DB time by wait class• Aggregated over 15 second intervals

Page 26: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Sampled vs. cumulative DB time

Page 27: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Where is DB time used?

• ADDM

• AWR and AWR compare periods reports

• EM Performance page and drill downs

• ASH report

• Server-generated Alerts

Page 28: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.
Page 29: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

EM Performance page

• Cumulative DB time by wait class• v$waitclassmetric_history and v$sysmetric_history• 1 minute intervals

Page 30: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

DB Time Tuning

• DB Time can be aggregated at multiple levels:• Database / instance• Service / module / action• Session / user / client id• SQL id / rowsource

• Performance improvement for Oracle database means doing the same work in less DB Time

Page 31: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Performance Problem Resolution 101

• Discover the problem:• User phone call or other complaint • Metric threshold alert or system monitoring

• Scope the problem:• How widespread is it?• How severe is it?• In other words: Who or what is wasting DB Time and how

much is being wasted?

• Diagnose the problem

• Scope the solution• How much of the pain can be relieved?

Page 32: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The DB Time Method

1. Scope

2. Set Goal

3. Investigate DB time distribution

4. Identify the largest potential for improvement

5. Modify system

6. Evaluate against Goal

Page 33: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The DB Time Method

• Scope• What is the problem?

• Business Requirements• Resource capacity• Resource contention

• System wide or individual Business Function

Page 34: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The DB Time Method

• Set Goal• Quantitative • Establishes the STOP TUNING criteria• Should be business driven for applications (X per day)

Page 35: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The DB Time Method

• Investigate DB time distribution• Identify major contributors to DB time at the selected scope• System scope

• V$SYS_TIME_MODEL• V$ACTIVE_SESSION_HISTORY• V$SQL• Identify high load service, sessions and SQL• Identify resource constraints or contention

Page 36: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The DB Time Method

• Investigate DB time distribution• Session scope

• V$SESS_TIME_MODEL• V$ACTIVE_SESSION_HISTORY• Identify if database is the problem• Identify high load SQL• Identify application efficiency issues• Identify resource constraints or contention

Page 37: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The DB Time Method

• Identify the largest potential for improvement• What can be changed that will produce the greatest

reduction in ‘scoped’ DB time?• Parameters• System• Application• SQL• Design

• Modify system

Page 38: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

The DB Time Method

• Evaluate against Goal • Did our changes to the system achieve our goal?• If not return to step 3 and repeat • If we have reached our goal STOP

Page 39: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.
Page 40: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.
Page 41: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.
Page 42: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.
Page 43: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

Summary

DB Time is the fundamental performance metric

The DB Time Method uses many different sources of DB time within the database to allow many different scopes of performance tuning

Time based diagnosis removes ‘value judgments’ from performance analysis

Page 44: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.

New In 11g – Enhancements for RAC

• ADDM has “Database” analysis mode• New AWR “Database” report• EM Performance screens for RAC enhanced to

support new server capabilities.

Page 45: DB-Time-based Oracle Performance Tuning: Theory and Practice Graham Wood, Uri Shaft, John Beresniewicz Oracle Corporation RMOUG Feb 2008.