Virtathon 7/2011
Who we are
Uday Moogala
Sr. Principal Engineer with Oracle Apps Development 15 years in the Oracle Database arena
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
Identify
(app is slow)
Quantify
(takes 1m)
When
Where
Timeline
Component
(MT or DB or N/W)
Analyze
How Why
Root Cause
Non-DB Time
DB Time
An example
Browse Books
Add to Cart
Checkout
TIME
On CPU
I/O
On CPU
I/O
v$active_session_history
(1 second intervals)
dba_hist_active_sess_history
(10 second intervals)
Browse Books
Add to Cart
Checkout
21 ASH Samples
TIME
- 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?
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
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
DBMS_XPLAIN.DISPLAY_AWR
- Plan is from AWR (DBA_HIST% views) - Runtime (actual) stats are not displayed - Sample output
Sample output
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
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 )
Q & A