18
Part 1 : What, When and How Virtathon 7/2011 Uday Moogala Vlado Barun

Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Embed Size (px)

Citation preview

Page 1: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Part 1 : What, When and How

Virtathon 7/2011Uday MoogalaVlado Barun

Page 2: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

• Uday Moogala– Sr. Principal Engineer with Oracle Apps Development– 15 years in the Oracle Database arena

• Vlado Barun, M.Sc.– Sr. Principal Performance Engineer with Oracle Cloud

Services– OCP, OCE SQL, MCP– 15 years in the Database Arena (Oracle - 10 years)

Who we are

Page 3: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

All the views expressed in this presentation are the opinion of the authors and do notnecessarily reflect the views of Oracle America,Inc.

The queries are provided "as is", without warranty of any kind, expressed or implied.

Disclaimer

Page 4: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

How to approach a SQL performance issue

What diagnostic data to gather

Generating and interpreting AWR ReportASH Reports SQL Execution Plans Real-Time SQL Monitoring Reports

Agenda

Page 5: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

In order to know what to fix, we need to be able to see what’s broken!

- Dan Roam

Page 6: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

What Identify(app is slow)

Quantify(takes 1m)

Timeline(in peak hours)

Component(MT or DB or N/W)

Flow chart

Root Cause(Stats not updated)

AWR/ASH, Trace,Apps Logs/Tables,OS/IO stats etc

SQL/Object Stats, Execution Plans, etc

InitialData

collec-tion

How Much

When

Where

How

Why

Analyze

Additional

Datacollec-

tion

Understanding the issue…

Page 7: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Non-DB Time

DB Time

Getting to know the System…

Page 8: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

I/OOn CPU I/OOn CPU

Browse Books

Read ReviewsFor One Book Add to Cart Checkout

TIME = time spent in database

= user/network/app tier time

An example…

Page 9: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

= time spent in database

SQL Trace (Microsecond level)Application Logging (custom level)

Browse Books

Read ReviewsFor One Book Add to Cart Checkout

TIME

v$active_session_history (1 second intervals)

dba_hist_active_sess_history (10 second intervals)

Gathering Performance Data…(SQL Trace, ASH)

21 ASH Samples

3 ASH Samples in AWR

Page 10: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Automatic Workload Repository (AWR)

Collects database performance statistics- Objects (access and usage statistics)- SQL Statement statistics- Wait events statistics- System statistics- ASH Statistics (DBA_HIST_ACTIVE_SESS_HISTORY)- Time Model Statistics based on time usage for activities- Every 1 hr by default

Stored in DBA_HIST% views

How to access?-$ORACLE_HOME/rdbms/admin/awrrpt.sql- OEM- Other tools

Sample output

Page 11: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Active Session History (ASH)

Samples the current state of all active sessions- 1 second samples- Stores various attributes (dimensions) of a session

Stored in - V$ACTIVE_SESSION_HISTORY

- 1-second sampling rate

- DBA_HIST_ACTIVE_SESS_HISTORY -Sub-sampling to disk into AWR Snapshot- 1-in-10 samples

How to access?-$ORACLE_HOME/rdbms/admin/ashrpt.sql, ashrpti.sql- OEM- Other tools

Sample output

Page 12: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Active Session History (ASH) - Dimensions

When SAMPLE_ID SAMPLE_TIME

Session SESSION_ID SESSION_SERIAL# SESSION_TYPE SESSION_STATE USER_ID QC_INSTANCE_ID QC_SESSION_ID QC_SESSION_SERIAL# CLIENT_ID IN and IS columns

SQL SQL_ID IS_SQLID_CURRENT SQL_CHILD_NUMBER SQL_OPCODE SQL_OPNAME TOP_LEVEL_SQL_ID TOP_LEVEL_SQL_OPCODE SQL_EXEC_ID SQL_EXEC_START SQL_PLAN_HASH_VALUE SQL_PLAN_OPTIONS

Row Source SQL_PLAN_LINE_ID SQL_PLAN_OPERATION

Waits EVENT EVENT_ID EVENT# SEQ# P1TEXT P1 P2TEXT P2 P3TEXT P3 WAIT_CLASS WAIT_CLASS_ID WAIT_TIME TIME_WAITED CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK# CURRENT_ROW#

Blocking Session BLOCKING_SESSION_STATUS BLOCKING_SESSION BLOCKING_SESSION_SERIAL# BLOCKING_INST_ID BLOCKING_HANGCHAIN_INFO

Object CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK# CURRENT_ROW#

Application SERVICE_HASH PROGRAM MODULE ACTION MACHINE

Statistics TM_DELTA_TIME TM_DELTA_CPU_TIME TM_DELTA_DB_TIME DELTA_TIME DELTA_READ_IO_REQUESTS DELTA_WRITE_IO_REQUESTS DELTA_READ_IO_BYTES DELTA_WRITE_IO_BYTES DELTA_INTERCONNECT_IO_BYTES PGA_ALLOCATED TEMP_SPACE_ALLOCATED

Page 13: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

SQL Execution Plans

DBMS_XPLAIN.DISPLAY_CURSOR- Plan is from memory- Predicates and outline data- most useful when ‘statistics_level’ set to ALL or with gather_plan_statistics hint-Sample output

DBMS_XPLAIN.DISPLAY_AWR- Plan is from AWR (DBA_HIST% views)- Runtime (actual) stats are not displayed- Sample output

Sample output

Page 14: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Real-Time SQL Monitoring

Monitors SQLs while they are running

Automatically monitors parallel SQLs and SQLs taking more than 5 CPU seconds

- Plan is from memory- Predicates- CPU and Elapsed Time- No. of reads and writes- Waits

Stored in V$SQL_MONITOR and V$SQL_PLAN_MONITOR views

How to access?- DBMS_SQLTUNE.REPORT_SQL_MONITOR- Enterprise Manager

Sample output

Page 15: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Summary

- AWR Report - Identified SQL issue- Get report snapshots as close as possible to the issue

- ASH Report- At system level to identify the session- At session level to identify the SQL- At SQL level to identify the row source, object, and wait events- Analyze samples taken during problematic SQL execution

- SQL Execution Plans- Dbms_Xplain.Display_Cursor- Dbms_Xplain.Display_AWR- set STATISTICS_LEVEL to ‘ALL’ or put GATHER_PLAN_STATISTICS hint

- Real-Time SQL Monitoring Report- To monitor the long running or parallel SQL- Take several reports and analyze the issue

Page 16: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

SQL Tuning– Trace files– SQLT output (MOS Doc:

215187.1)– Trace Analyzer (MOS Doc :

224270.1)– AWR Report (MOS Doc :

748642.1)– AWR SQL Report

(awrsqrpt.sql)– 11g Real-Time SQL Monitoring – SQL Tuning Advisor

PL/SQL Tuning– Product logs– PL/SQL Profiler (MOS Doc :

808005.1)

Forms Tuning– Forms Tracing (MOS Doc :

373548.1)– Generic MOS Doc : 438652.1

Reports Tracing– MOS Doc: 111311.1

Database Tuning– AWR Report (MOS Doc :

748642.1)– ADDM report (MOS Doc :

250655.1)– Active Session History (ASH)

Report – LTOM output (MOS Doc :

352363.1)

Middletier Tuning– JVM Logs– Third Party Tools

OS– OSWatcher (MOS Doc :

301137.1)

Reference

Page 17: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Reference

- Performance Fundamentals for Oracle Database 10g and 11g by Graham Wood and John Beresniewicz (http://www.oracle.com/technetwork/database/focus-areas/manageability/db-perf-tuning-ow08-131582.pdf )

- ASH - Active Session History (https://sites.google.com/site/embtdbo/wait-event-documentation/ash---active-session-history)

Page 18: Performance Tuning With Oracle ASH and AWR. Part 1 How And What

Q & A