SlideShare una empresa de Scribd logo
1 de 32
Descargar para leer sin conexión
ASH Outliers: 
Detecting Unusual Events in Active Session History 
John Beresniewicz, Oracle USA
Agenda 
• ASH Fundamentals 
• Wait Events and ASH 
• Event Histograms 
• Event Significance Levels 
• SQL to Find Outliers in ASH 
• Handling the GV$ problem
Motivating Use Case 
• Unusually long wait events (outliers) suspected to 
trigger cascade-effect performance incidents 
! 
• RAC performance experts claim EM Top Activity not 
helpful as aggregation masks outlier events 
! 
• Can we see if ASH has sampled any such events? 
• If none observed does not mean they have not happened 
• However ASH sampling is biased to longer events
ASH Fundamentals
ASH and DB Time
ASH Fact Table Dimensions
ASH Math 
• COUNT(*) = DB TIME (secs) 
• Basic in-memory (V$ASH) formula 
! 
• The Kurtz Construct is nice 
• SUM(1) = DB Time (secs) for in-memory 
• SUM(10) = DB TIME (secs) for on-disk 
! 
• DB Time Method analysis: 
• Dimensional GROUP BY over COUNT(*)
Good ASH Math: ASH Analytics
Group by Wait Event within Wait Class
Add SQL_ID Grouping Dimension
Bad ASH Math 
• SQL observed using 9 secs of CPU every 10 secs
Wait Events and ASH 
• ASH samples actively waiting sessions 
• Wait time is unknown at sample time 
• The “fix up” writes actual wait time into TIME_WAITED 
! 
• ASH is a biased sampler of wait events 
• Longer events have higher probability of being sampled 
! 
• Avoid the temptation of TIME_WAITED 
• AVG(time_waited) DOES NOT estimate avg wait times 
• MIN and MAX do not work either 
• Except when MAX exceeds 1-second
The ASH “fix up” 
• ASH columns may be unknown at sampling time 
• TIME_WAITED: session is still waiting 
• PLAN_HASH: session is still optimizing SQL 
• GC events: event details unknown at event initiation 
• Certain time model bit vector columns 
! 
• ASH “fixes up” missing data during subsequent 
sample processing 
• TIME_WAITED fixed up in last event sample 
! 
• Querying current ASH may return un-fixed rows 
• Should not be a problem generally
ON CPU and ASH 
• ASH row status “ON CPU” derived, not observed 
• Session is in a database call 
• Session is NOT in a wait event (idle or non-idle) 
! 
• Un-instrumented waits => “ON CPU” 
• These are bugs and should be rare, but have happened 
! 
• Session on run queue may be WAITING or ON CPU 
• Depends on state prior to going onto run queue
V$EVENT_HISTOGRAM 
• Histogram buckets of event wait times 
! 
• Captures statistical distribution of wait times 
! 
• All events since instance startup counted in some 
bucket 
! 
• Exponential time bucketing scheme captures long-tail 
distributions efficiently
V$EVENT_HISTOGRAM 
SQL> desc v$event_histogram 
Name Type 
---------------------------- ---------------------------- 
EVENT# NUMBER 
EVENT VARCHAR2(64) 
WAIT_TIME_MILLI NUMBER 
WAIT_COUNT NUMBER 
LAST_UPDATE_TIME VARCHAR2(64)
Event Histogram Time Buckets 
SQL> select distinct 
wait_time_milli 
,log(2,wait_time_milli) 
from 
v$event_histogram 
order by 1; 
WAIT_TIME_MILLI LOG(2,WAIT_TIME_MILLI) 
--------------- ---------------------- 
1 0 
2 1 
4 2 
8 3 
16 4 
32 5 
64 6 
128 7 
256 8 
512 9 
1024 10
I/O Event Histogram
Latch Wait Event Histogram
Histogram Math 
• Histograms capture probability distribution of 
TIME_WAITED by event over this startup cycle 
Σ 
Σ 
WaitCount 
Pr(time _ waited bucket ) 
< = < 
allbuckets 
bucket N 
N WaitCount
Significance of Histogram Buckets 
# 
! ! ! 
" 
& 
$ $ $ % 
bucket >= 
N 
Σ 
WaitCount 
Significance 1 
= − Σ 
bucketN WaitCount 
allbuckets 
• Measures the cumulative distribution function of 
TIME_WAITED probabilities represented by the 
histograms (per bucket) 
! 
• Every event in the bucket has at least this significance
Defining “Outlier Events” 
• Events with low probability of occurrence 
! 
• Events with high significance value 
! 
• Q: Has ASH sampled any such events?
“Outlier” = “Unusual”
Finding Outlier Events in ASH 
• Which ASH rows (if any) represent wait events with 
significantly long TIME_WAITED against the event 
histogram record? 
! 
• Two step process: 
! 
1. Compute event histogram bucket significance 
2. Join ASH to histograms and filter by significance
Step 1: Compute Bucket Significance 
WITH EH$stats 
as 
(select 
EH.* 
,ROUND(1 - (tot_count - bucket_tot_count + wait_count) / tot_count,6) 
as event_bucket_siglevel 
from 
(select event# 
,event 
,wait_time_milli 
,wait_count 
,ROUND(LOG(2,wait_time_milli)) as event_bucket 
,SUM(wait_count) OVER (PARTITION BY event#) as tot_count 
,SUM(wait_count) OVER (PARTITION BY event# ORDER BY wait_time_milli 
RANGE UNBOUNDED PRECEDING) 
as bucket_tot_count 
from v$event_histogram 
) EH 
)
Step 2: Join ASH to Buckets and Filter 
select 
EH.event_bucket 
,ASH.sample_id 
,ASH.session_id 
,EH.event_bucket_siglevel as bucket_siglevel 
,ASH.event 
,ASH.time_waited/1000 ASH_time_waited_milli 
,ASH.sql_id 
from 
EH$stats EH 
,v$active_session_history ASH 
where 
EH.event# = ASH.event# 
and EH.event_bucket_siglevel > &siglevel 
and EH.event_bucket = CASE ASH.time_waited 
WHEN 0 THEN null 
ELSE TRUNC(LOG(2,ASH.time_waited/1000))+1 
END 
order by 
sample_id, event, session_id 
;
DEMO?
The GV$ Problem 
• Motivating use case is for RAC 
! 
• Execute V$ query on all instances? 
• Too much effort 
! 
• Convert V$ query to GV$ query? 
• GV$ remote joins not optimized 
• QC will pull V$ASH and V$EVENT_HISTOGRAM and join locally 
! 
• Neither of these “solutions” is acceptable
GV$ Table Function 
• Table function distributes V$ cursor across RAC 
nodes and marshals result sets 
! 
• Perfect solution for this use case 
SELECT … FROM TABLE GV$( (CURSOR( SELECT FROM V$)))
DEMO?
Comments and Caveats 
• Highly significant events may not be sampled 
! 
• Works best for long-tailed distributions 
• Bi-modal, single-bucket, timeout events not well-behaved 
! 
• Exponential bucket sizing gets coarse quickly 
• Significance levels increase in big jumps 
• Important distinctions may hide inside large buckets 
! 
• An interesting and unusual application of ASH where 
TIME_WAITED is the key 
• Does it help with the motivating use case?
Ash Outliers UKOUG2011

Más contenido relacionado

La actualidad más candente

VirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWRVirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWR
Kristofferson A
 
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
Kristofferson A
 
Whitepaper: Mining the AWR repository for Capacity Planning and Visualization
Whitepaper: Mining the AWR repository for Capacity Planning and VisualizationWhitepaper: Mining the AWR repository for Capacity Planning and Visualization
Whitepaper: Mining the AWR repository for Capacity Planning and Visualization
Kristofferson A
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
udaymoogala
 
Whitepaper: Where did my CPU go?
Whitepaper: Where did my CPU go?Whitepaper: Where did my CPU go?
Whitepaper: Where did my CPU go?
Kristofferson A
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
Mao Geng
 
OOW Unconference 2010: Mining the AWR repository for Capacity Planning, Visua...
OOW Unconference 2010: Mining the AWR repository for Capacity Planning, Visua...OOW Unconference 2010: Mining the AWR repository for Capacity Planning, Visua...
OOW Unconference 2010: Mining the AWR repository for Capacity Planning, Visua...
Kristofferson A
 

La actualidad más candente (20)

Awr + 12c performance tuning
Awr + 12c performance tuningAwr + 12c performance tuning
Awr + 12c performance tuning
 
Analyzing and Interpreting AWR
Analyzing and Interpreting AWRAnalyzing and Interpreting AWR
Analyzing and Interpreting AWR
 
AWR reports-Measuring CPU
AWR reports-Measuring CPUAWR reports-Measuring CPU
AWR reports-Measuring CPU
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
 
Ash and awr deep dive hotsos
Ash and awr deep dive hotsosAsh and awr deep dive hotsos
Ash and awr deep dive hotsos
 
VirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWRVirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWR
 
AWR DB performance Data Mining - Collaborate 2015
AWR DB performance Data Mining - Collaborate 2015AWR DB performance Data Mining - Collaborate 2015
AWR DB performance Data Mining - Collaborate 2015
 
Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014
 
Advanced tips for making Oracle databases faster
Advanced tips for making Oracle databases fasterAdvanced tips for making Oracle databases faster
Advanced tips for making Oracle databases faster
 
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
 
Whitepaper: Mining the AWR repository for Capacity Planning and Visualization
Whitepaper: Mining the AWR repository for Capacity Planning and VisualizationWhitepaper: Mining the AWR repository for Capacity Planning and Visualization
Whitepaper: Mining the AWR repository for Capacity Planning and Visualization
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
 
Whitepaper: Where did my CPU go?
Whitepaper: Where did my CPU go?Whitepaper: Where did my CPU go?
Whitepaper: Where did my CPU go?
 
Earl Shaffer Oracle Performance Tuning pre12c 11g AWR uses
Earl Shaffer Oracle Performance Tuning pre12c 11g AWR usesEarl Shaffer Oracle Performance Tuning pre12c 11g AWR uses
Earl Shaffer Oracle Performance Tuning pre12c 11g AWR uses
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
 
OOW Unconference 2010: Mining the AWR repository for Capacity Planning, Visua...
OOW Unconference 2010: Mining the AWR repository for Capacity Planning, Visua...OOW Unconference 2010: Mining the AWR repository for Capacity Planning, Visua...
OOW Unconference 2010: Mining the AWR repository for Capacity Planning, Visua...
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 
Oracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptOracle Database Performance Tuning Concept
Oracle Database Performance Tuning Concept
 
Oracle Database : Addressing a performance issue the drilldown approach
Oracle Database : Addressing a performance issue the drilldown approachOracle Database : Addressing a performance issue the drilldown approach
Oracle Database : Addressing a performance issue the drilldown approach
 
Think Exa!
Think Exa!Think Exa!
Think Exa!
 

Similar a Ash Outliers UKOUG2011

ASH Archit ecture and Advanced Usage.pdf
ASH Archit ecture and Advanced Usage.pdfASH Archit ecture and Advanced Usage.pdf
ASH Archit ecture and Advanced Usage.pdf
tricantino1973
 
200603ash.pdf Performance Tuning Oracle DB
200603ash.pdf Performance Tuning Oracle DB200603ash.pdf Performance Tuning Oracle DB
200603ash.pdf Performance Tuning Oracle DB
cookie1969
 
Empower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instrumentsEmpower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instruments
Marco Tusa
 
What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)
Jason Strate
 
ASH and AWR Performance Data by Kellyn Pot'Vin
ASH and AWR Performance Data by Kellyn Pot'VinASH and AWR Performance Data by Kellyn Pot'Vin
ASH and AWR Performance Data by Kellyn Pot'Vin
Enkitec
 

Similar a Ash Outliers UKOUG2011 (20)

ASH Archit ecture and Advanced Usage.pdf
ASH Archit ecture and Advanced Usage.pdfASH Archit ecture and Advanced Usage.pdf
ASH Archit ecture and Advanced Usage.pdf
 
200603ash.pdf Performance Tuning Oracle DB
200603ash.pdf Performance Tuning Oracle DB200603ash.pdf Performance Tuning Oracle DB
200603ash.pdf Performance Tuning Oracle DB
 
ASH and AWR on DB12c
ASH and AWR on DB12cASH and AWR on DB12c
ASH and AWR on DB12c
 
SQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tangoSQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tango
 
active_session_history_oracle_performance.ppt
active_session_history_oracle_performance.pptactive_session_history_oracle_performance.ppt
active_session_history_oracle_performance.ppt
 
Rmoug ashmaster
Rmoug ashmasterRmoug ashmaster
Rmoug ashmaster
 
OTN tour 2015 AWR data mining
OTN tour 2015 AWR data miningOTN tour 2015 AWR data mining
OTN tour 2015 AWR data mining
 
Ash and awr performance data2
Ash and awr performance data2Ash and awr performance data2
Ash and awr performance data2
 
Azure stream analytics by Nico Jacobs
Azure stream analytics by Nico JacobsAzure stream analytics by Nico Jacobs
Azure stream analytics by Nico Jacobs
 
Empower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instrumentsEmpower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instruments
 
Deep Dive: Amazon Redshift (March 2017)
Deep Dive: Amazon Redshift (March 2017)Deep Dive: Amazon Redshift (March 2017)
Deep Dive: Amazon Redshift (March 2017)
 
Deep Dive Redshift, with a focus on performance
Deep Dive Redshift, with a focus on performanceDeep Dive Redshift, with a focus on performance
Deep Dive Redshift, with a focus on performance
 
IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...
IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...
IMCSummit 2015 - Day 2 Developer Track - A Reference Architecture for the Int...
 
What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)What are you waiting for? (#SQLSat211)
What are you waiting for? (#SQLSat211)
 
Reference architecture for Internet of Things
Reference architecture for Internet of ThingsReference architecture for Internet of Things
Reference architecture for Internet of Things
 
Reference architecture for Internet Of Things
Reference architecture for Internet Of ThingsReference architecture for Internet Of Things
Reference architecture for Internet Of Things
 
Sql Server Statistics
Sql Server StatisticsSql Server Statistics
Sql Server Statistics
 
ASH and AWR Performance Data by Kellyn Pot'Vin
ASH and AWR Performance Data by Kellyn Pot'VinASH and AWR Performance Data by Kellyn Pot'Vin
ASH and AWR Performance Data by Kellyn Pot'Vin
 
Sherlock holmes for dba’s
Sherlock holmes for dba’sSherlock holmes for dba’s
Sherlock holmes for dba’s
 
A gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor modelA gentle introduction into AKKA and the actor model
A gentle introduction into AKKA and the actor model
 

Más de John Beresniewicz

Más de John Beresniewicz (6)

ASHviz - Dats visualization research experiments using ASH data
ASHviz - Dats visualization research experiments using ASH dataASHviz - Dats visualization research experiments using ASH data
ASHviz - Dats visualization research experiments using ASH data
 
NoSQL is Anti-relational
NoSQL is Anti-relationalNoSQL is Anti-relational
NoSQL is Anti-relational
 
AAS Deeper Meaning
AAS Deeper MeaningAAS Deeper Meaning
AAS Deeper Meaning
 
JB Design CV: products / mockups / experiments
JB Design CV: products / mockups / experiments JB Design CV: products / mockups / experiments
JB Design CV: products / mockups / experiments
 
Proactive performance monitoring with adaptive thresholds
Proactive performance monitoring with adaptive thresholdsProactive performance monitoring with adaptive thresholds
Proactive performance monitoring with adaptive thresholds
 
Contract-oriented PLSQL Programming
Contract-oriented PLSQL ProgrammingContract-oriented PLSQL Programming
Contract-oriented PLSQL Programming
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Ash Outliers UKOUG2011

  • 1. ASH Outliers: Detecting Unusual Events in Active Session History John Beresniewicz, Oracle USA
  • 2. Agenda • ASH Fundamentals • Wait Events and ASH • Event Histograms • Event Significance Levels • SQL to Find Outliers in ASH • Handling the GV$ problem
  • 3. Motivating Use Case • Unusually long wait events (outliers) suspected to trigger cascade-effect performance incidents ! • RAC performance experts claim EM Top Activity not helpful as aggregation masks outlier events ! • Can we see if ASH has sampled any such events? • If none observed does not mean they have not happened • However ASH sampling is biased to longer events
  • 5. ASH and DB Time
  • 6. ASH Fact Table Dimensions
  • 7. ASH Math • COUNT(*) = DB TIME (secs) • Basic in-memory (V$ASH) formula ! • The Kurtz Construct is nice • SUM(1) = DB Time (secs) for in-memory • SUM(10) = DB TIME (secs) for on-disk ! • DB Time Method analysis: • Dimensional GROUP BY over COUNT(*)
  • 8. Good ASH Math: ASH Analytics
  • 9. Group by Wait Event within Wait Class
  • 10. Add SQL_ID Grouping Dimension
  • 11. Bad ASH Math • SQL observed using 9 secs of CPU every 10 secs
  • 12. Wait Events and ASH • ASH samples actively waiting sessions • Wait time is unknown at sample time • The “fix up” writes actual wait time into TIME_WAITED ! • ASH is a biased sampler of wait events • Longer events have higher probability of being sampled ! • Avoid the temptation of TIME_WAITED • AVG(time_waited) DOES NOT estimate avg wait times • MIN and MAX do not work either • Except when MAX exceeds 1-second
  • 13. The ASH “fix up” • ASH columns may be unknown at sampling time • TIME_WAITED: session is still waiting • PLAN_HASH: session is still optimizing SQL • GC events: event details unknown at event initiation • Certain time model bit vector columns ! • ASH “fixes up” missing data during subsequent sample processing • TIME_WAITED fixed up in last event sample ! • Querying current ASH may return un-fixed rows • Should not be a problem generally
  • 14. ON CPU and ASH • ASH row status “ON CPU” derived, not observed • Session is in a database call • Session is NOT in a wait event (idle or non-idle) ! • Un-instrumented waits => “ON CPU” • These are bugs and should be rare, but have happened ! • Session on run queue may be WAITING or ON CPU • Depends on state prior to going onto run queue
  • 15. V$EVENT_HISTOGRAM • Histogram buckets of event wait times ! • Captures statistical distribution of wait times ! • All events since instance startup counted in some bucket ! • Exponential time bucketing scheme captures long-tail distributions efficiently
  • 16. V$EVENT_HISTOGRAM SQL> desc v$event_histogram Name Type ---------------------------- ---------------------------- EVENT# NUMBER EVENT VARCHAR2(64) WAIT_TIME_MILLI NUMBER WAIT_COUNT NUMBER LAST_UPDATE_TIME VARCHAR2(64)
  • 17. Event Histogram Time Buckets SQL> select distinct wait_time_milli ,log(2,wait_time_milli) from v$event_histogram order by 1; WAIT_TIME_MILLI LOG(2,WAIT_TIME_MILLI) --------------- ---------------------- 1 0 2 1 4 2 8 3 16 4 32 5 64 6 128 7 256 8 512 9 1024 10
  • 19. Latch Wait Event Histogram
  • 20. Histogram Math • Histograms capture probability distribution of TIME_WAITED by event over this startup cycle Σ Σ WaitCount Pr(time _ waited bucket ) < = < allbuckets bucket N N WaitCount
  • 21. Significance of Histogram Buckets # ! ! ! " & $ $ $ % bucket >= N Σ WaitCount Significance 1 = − Σ bucketN WaitCount allbuckets • Measures the cumulative distribution function of TIME_WAITED probabilities represented by the histograms (per bucket) ! • Every event in the bucket has at least this significance
  • 22. Defining “Outlier Events” • Events with low probability of occurrence ! • Events with high significance value ! • Q: Has ASH sampled any such events?
  • 24. Finding Outlier Events in ASH • Which ASH rows (if any) represent wait events with significantly long TIME_WAITED against the event histogram record? ! • Two step process: ! 1. Compute event histogram bucket significance 2. Join ASH to histograms and filter by significance
  • 25. Step 1: Compute Bucket Significance WITH EH$stats as (select EH.* ,ROUND(1 - (tot_count - bucket_tot_count + wait_count) / tot_count,6) as event_bucket_siglevel from (select event# ,event ,wait_time_milli ,wait_count ,ROUND(LOG(2,wait_time_milli)) as event_bucket ,SUM(wait_count) OVER (PARTITION BY event#) as tot_count ,SUM(wait_count) OVER (PARTITION BY event# ORDER BY wait_time_milli RANGE UNBOUNDED PRECEDING) as bucket_tot_count from v$event_histogram ) EH )
  • 26. Step 2: Join ASH to Buckets and Filter select EH.event_bucket ,ASH.sample_id ,ASH.session_id ,EH.event_bucket_siglevel as bucket_siglevel ,ASH.event ,ASH.time_waited/1000 ASH_time_waited_milli ,ASH.sql_id from EH$stats EH ,v$active_session_history ASH where EH.event# = ASH.event# and EH.event_bucket_siglevel > &siglevel and EH.event_bucket = CASE ASH.time_waited WHEN 0 THEN null ELSE TRUNC(LOG(2,ASH.time_waited/1000))+1 END order by sample_id, event, session_id ;
  • 27. DEMO?
  • 28. The GV$ Problem • Motivating use case is for RAC ! • Execute V$ query on all instances? • Too much effort ! • Convert V$ query to GV$ query? • GV$ remote joins not optimized • QC will pull V$ASH and V$EVENT_HISTOGRAM and join locally ! • Neither of these “solutions” is acceptable
  • 29. GV$ Table Function • Table function distributes V$ cursor across RAC nodes and marshals result sets ! • Perfect solution for this use case SELECT … FROM TABLE GV$( (CURSOR( SELECT FROM V$)))
  • 30. DEMO?
  • 31. Comments and Caveats • Highly significant events may not be sampled ! • Works best for long-tailed distributions • Bi-modal, single-bucket, timeout events not well-behaved ! • Exponential bucket sizing gets coarse quickly • Significance levels increase in big jumps • Important distinctions may hide inside large buckets ! • An interesting and unusual application of ASH where TIME_WAITED is the key • Does it help with the motivating use case?