Anda di halaman 1dari 18

Part 1 : What, When and How

Virtathon 7/2011

Uday Moogala Vlado Barun

Who we are

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)

Disclaimer

All the views expressed in this presentation are the opinion of the authors and do not necessarily reflect the views of Oracle America, Inc. The queries are provided "as is", without warranty of any kind, expressed or implied.

Agenda

How to approach a SQL performance issue What diagnostic data to gather Generating and interpreting
AWR Report ASH Reports SQL Execution Plans Real-Time SQL Monitoring Reports

In order to know what to fix, we need to be able to see whats broken! - Dan Roam

Understanding the issue

What How Much

Identify

(app is slow)

Quantify
(takes 1m)

When
Where

Timeline

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

Initial Data collection

(in peak hours)

Component

(MT or DB or N/W)

Analyze

How Why

Flow chart Addition al Data collection

Root Cause

(Stats not updated)

SQL/Object Stats, Execution Plans, etc

Getting to know the System

Non-DB Time

DB Time

An example

Browse Books

Read Reviews For One Book

Add to Cart

Checkout

= time spent in database = user/network/app tier time

TIME

On CPU

I/O

On CPU

I/O

Gathering Performance Data


(SQL Trace, ASH)

v$active_session_history
(1 second intervals)

dba_hist_active_sess_history
(10 second intervals)

3 ASH Samples in AWR

Browse Books

Read Reviews For One Book

Add to Cart

Checkout
21 ASH Samples

TIME

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

= time spent in database

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

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

Active Session History (ASH) - Dimensions


When
SAMPLE_ID SAMPLE_TIME

Row Source
SQL_PLAN_LINE_ID SQL_PLAN_OPERATION

Object
CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK# CURRENT_ROW#

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

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#

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

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

Blocking Session
BLOCKING_SESSION_STATUS BLOCKING_SESSION BLOCKING_SESSION_SERIAL# BLOCKING_INST_ID BLOCKING_HANGCHAIN_INFO

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

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

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

Reference
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

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)

PL/SQL Tuning
Product logs PL/SQL Profiler (MOS Doc : 808005.1)

Middletier Tuning
JVM Logs Third Party Tools

Forms Tuning
Forms Tracing (MOS Doc : 373548.1) Generic MOS Doc : 438652.1

OS
OSWatcher (MOS Doc : 301137.1)

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)

Q & A

Anda mungkin juga menyukai