SlideShare a Scribd company logo
Architect, Enterprise and Cloud Manageability
Oracle America
John Beresniewicz
Know your performance fundamentals
DB Time, Average Active Sessions, and ASH Math
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, timing, and pricing of any features or functionality described for Oracle’s
products may change and remains at the sole discretion of Oracle Corporation.
Safe harbor statement
Copyright © 2020, Oracle and/or its affiliates2
Copyright © 2020, Oracle and/or its affiliates3
4
3
2
1
Issues
ASH Math
Average Active Sessions
Database Time
Agenda
Copyright © 2020, Oracle and/or its affiliates | Confidential: Internal/Restricted/Highly Restricted4
Concepts
• The core ideas
Instrumentation
• Services supporting the core ideas
Visualization
• Presentation of concepts using instrumentation
Approach
Copyright © 2020, Oracle and/or its affiliates5
Database Time
Copyright © 2020, Oracle and/or its affiliates6
Performance is about work and time
Performance measures:
• Throughput = work / time
• Latency (response time) = time / work
Database time is about time spent doing database work
Database time is the foundation of Diagnostic and Tuning Packs:
• ADDM, AWR, SPA, SQL Monitor, EM Perf Page, Top Activity, ASH Analytics
Logic of DB Time
Copyright © 2020, Oracle and/or its affiliates7
Time spent processing database client calls
Specifically:
• Foreground time spent executing database calls (SQL)
• Actively working (on CPU) or waiting to work (in wait)
Note:
• Idle wait time is not included in DB Time
• Background time is not included in DB Time
Definition of DB Time
Copyright © 2020, Oracle and/or its affiliates8
DB Time is spent on CPU or in wait
DB Time clock starts upon client call to DB and stops with response to client
Model of DB Time
CPU WAIT
DB TIME
Copyright © 2020, Oracle and/or its affiliates9
Timers built into code path to measure DB Time spent in certain operations:
• Call begin/exit (total time in call)
• Parsing
• PL/SQL compilation
CPU time fetched from OS
Can be tricky given call stack complexity
• V$SYS_TIME_MODEL
• DBA_HIST_SYS_TIME_MODEL
• V$SYSMETRIC_HISTORY
Instrumentation: Time Model
Copyright © 2020, Oracle and/or its affiliates10
The following are critical Time Model measures:
DB Time
• Clearest and coarsest instrumentation points, highly reliable
• Includes run-queue time on CPU saturated systems
DB CPU
• Fetched from OS counters by foregrounds
• Includes only actual time on CPU, not time on run-queue
Also:
• background cpu time
• background elapsed
Critical Measures
Copyright © 2020, Oracle and/or its affiliates11
DB call execution involves many queueing, serialization, and synchronization mechanisms
• Locks, latches, mutexes
• Cores / CPUs / instance caging
External I/O
DB code is instrumented to time these “wait events”
• V$WAITCLASSMETRIC_HISTORY (???)
• V$EVENT_HISTOGRAM
Instrumentation: Wait Model
DB CPU WAITUser I/O WAIT
DB Time
Copyright © 2020, Oracle and/or its affiliates12
CPU saturation is an apex problem
• Processing capacity exhausted, no more work can be done
Instrumentation distortion
• Wait event timing
• Invisible / missing DB Time
Visibility issues, difficult to measure
Run queue: silent killer
Copyright © 2020, Oracle and/or its affiliates13
Run-queue distortion: wait path
DB file scattered read Run queue CPU
actual event latency
measured event latency
1. Event finishes and foreground queues for CPU
2. End of wait timestamp requires CPU
3. Measured event latency includes run-queue time
end timestampbegin timestamp
Copyright © 2020, Oracle and/or its affiliates14
DB Time exceeds total DB CPU time under CPU saturation
Run-queue not always reliably measured
• Check V$OSSTAT.STAT_NAME = ’RSRC_MGR_CPU_WAIT_TIME’
Run-queue distortion: CPU path
CPU Run queue CPU
DB Time
DB CPU DB CPU
Copyright © 2020, Oracle and/or its affiliates15
Quantifying true CPU capacity increasingly difficult
• Hyper-threading
• Virtualization and hypervisors
• Containers and cloud
Core utilization is the used fraction of raw core time available
• When < 1 system is not CPU saturated
• When > 1 system exceeding raw core capacity through hyper-threading
Core Utilization
!" #$% + '()*+,-./0 )1.
23(1420 5672 ∗ )-,2 )-./5
Copyright © 2020, Oracle and/or its affiliates16
Viz: EM DB Performance Page
Copyright © 2020, Oracle and/or its affiliates17
Average Active Sessions
Copyright © 2020, Oracle and/or its affiliates18
Labeling the Perf Page chart
DB Time per sec = “Centi-users per second”?
Copyright © 2020, Oracle and/or its affiliates19
Over some time interval, e.g. an AWR snapshot
AAS is the rate at which DB Time is accumulates in the system
We also think of AAS as the load on the database
Typically, total sessions >> AAS (due to session idle time)
• However poor session management is a classic performance pitfall
Definition of AAS
!"#$%&# !'()"# *#++),-+ = !!* = /01 2)3#
#4%5+#6 ()3#
Copyright © 2020, Oracle and/or its affiliates20
AAS = rate of change of DB Time over time
Integrating AAS = computing DB Time
Perf Page is literally a picture of DB Time
AAS and DB Time
!"#$%& '&''$()' # =
+ ,- .$/&
+#
0
12
13
!"#$%& '&''$()' # +# = ,- .$/&
#2
#1
Copyright © 2020, Oracle and/or its affiliates21
AAS for comparisons:
• Across time periods – how does load vary?
• Across similar systems – which DB is busiest?
Per-core normalization
• Compare different systems’ profiles
• AWR1page script
Normalization and AAS
!""#(%&'()
*+,- *+./(
!""#(012)
*+,- *+./(
Copyright © 2020, Oracle and/or its affiliates22
Q: Whose time is DB Time?
A: Business entities using database services to accomplish time-bound goals
• Interactive end-users
• Automated business processes
”Enterprise time” is the same regardless of which database or service is being invoked
• One second spent waiting for DB1 response is no different than one waiting for DB2
Enterprise DB Time can be thought of as a fungible quantity
Fungibility of DB Time
Copyright © 2020, Oracle and/or its affiliates23
Viz: EM Enterprise Loadmap
Copyright © 2020, Oracle and/or its affiliates27
Active session state sampled into memory every second (1000 msec)
• Active = in DB call and not in idle wait
Fixes-up values unknown at sampling time
• TIME_WAITED
Sampled session state is either ON CPU or in WAIT event
• Session in WAIT is known
• Session presumed ON CPU if not in WAIT
Wait event samples biased toward longer latency waits
Mechanism design is latch-less, efficient, reliable
Instrumentation: Active Session History
Conforms to the model of DB Time
Copyright © 2020, Oracle and/or its affiliates28
Viz: EM Top Activity Page
Copyright © 2020, Oracle and/or its affiliates |29
ASH Math
Copyright © 2020, Oracle and/or its affiliates30
Decompose DB Time by aggregating ASH sample rows
• Grouped over dimensions, classic fact table query
• Many analysis columns: 30+ in DB 10.2, 110+ in DB 12.2
Filter and Aggregate to isolate and expose how DB Time is spent
Normalize to AAS: divide DB Time by aggregation interval time
Estimating DB Time using ASH
!"#$% ∗ = () *+,- (/-0/)
select trunc(sample_time,'MI’), sql_id
,sum(usecs_per_row)/(60*power(10,6)) as AAS
from v$active_session_history
group by trunc(sample_time,'MI’), sql_id;
Copyright © 2020, Oracle and/or its affiliates31
Summing samples is equivalent to computing Riemann estimate of DB Time integral
• !"#$% &'( )*+,-./ = *!%12.'.))1"$) %
• ∆% = )*+,-1$4 1$%.52*- = 1 ).!
The calculus of ASH Math
∆%
ASH
Sample
count
time
sessions
*!%12.'.))1"$) %
Copyright © 2020, Oracle and/or its affiliates32
Both are literal pictures of DB Time:
• Perf Page is top-down instrumentation:
• Time Model & Wait model
• Top Activity is bottom-up instrumentation
• ASH
It’s the Fundamental Theorem of Calculus!
Perf Page ≡ Top Activity Page
Copyright © 2020, Oracle and/or its affiliates33
Beware: the ASH sampler is biased toward longer latencies
• Higher probability of being sampled
Common mistakes:
• AVG(TIME_WAITED) ≠ average event latency
• SUM(TIME_WAITED) ≠ DB wait time
Bad ASH math
Copyright © 2020, Oracle and/or its affiliates34
Viz: ASH Analytics Loadmap
IN_CONNECTION_MGMT VARCHAR2(1)
IN_PARSE VARCHAR2(1)
IN_HARD_PARSE VARCHAR2(1)
IN_PLSQL_RPC VARCHAR2(1)
IN_PLSQL_COMPILATION VARCHAR2(1)
IN_JAVA_EXECUTION VARCHAR2(1)
IN_BIND VARCHAR2(1)
Copyright © 2020, Oracle and/or its affiliates35
ASH math can estimate DB Time spent in “un-timeable” operations
1. Timestamping may be relatively expensive for very low latency operations
2. Instead, set a session state bit ON when operation begins – very cheap
3. When operations completes, set the bit OFF
4. ASH sampler samples bit vector
5. Using ASH math: COUNT(samples with bit ON) = DB Time in operation
Bit vector magic
Copyright © 2020, Oracle and/or its affiliates36
So what can TIME_WAITED tell us?
Recall: ASH sampling is independent of session activity and on strict schedule
TIME_WAITED: advanced ASH math
time
wait event E CPUCPU
1000 ms
200 ms ASH Sample time
Pr # $%&'()* = ,-./#_12.-#3
4%&'(567 .68)9:%(
Copyright © 2020, Oracle and/or its affiliates37
• Questions:
• If a sampled 200 msec event counts for 1000 msec of DB Time, what about the other 800 msec?
• How can the likelihood of sampling an event provide an estimate for how often it occurs?
Estimated number of occurrences is number required to minimally cover sampling interval
TIME_WAITED: estimating event counts
!"#_%&'(#)*)+, = GREATEST
456789:; 9:<=>?58
#@A!_BC@#!D
, 1
1000 ms
200 ms
time
wait event E wait event E wait event E wait event E wait event E
Copyright © 2020, Oracle and/or its affiliates38
Estimating average latency properly
select wait_class
,TRUNC(DBtime_usecs / est_count) as AvgLatency_usec
,TRUNC(bad_ash_math) as bad_ash_math
from
(select wait_class
,SUM(GREATEST(usecs_per_row / time_waited, 1)) est_count
,SUM(usecs_per_row) DBtime_usecs
,AVG(time_waited) bad_ash_math
from
v$active_session_history
where time_waited > 0
group by wait_class
)
Copyright © 2020, Oracle and/or its affiliates39
Bad ASH math vs. properly estimated average latencies:
Results
WAIT_CLASS AVGLATENCY_USEC BAD_ASH_MATH
Concurrency 702 21139
User I/O 735 18380
Administrative 104910 135946
System I/O 543 855
Other 71 65951
Scheduler 9883 10901
Configuration 254143 330538
Cluster 155 5632
Application 277 26880
Commit 494 927
Network 399 51402
Idle 1004 1006
Copyright © 2020, Oracle and/or its affiliates40
Issues
Copyright © 2020, Oracle and/or its affiliates
Database is only one of many layers in the Enterprise technology stack
Determine how much DB Time contributes to total Enterprise time
Beware of instrumentation infatuation
DB Time is not the only relevant time
Database Storage
Client Services
Micro
services
Database Storage
response time profile
Copyright © 2020, Oracle and/or its affiliates42
Principal Database Engineer, AWS
Kevin Closson
“Everything is a CPU problem”
Copyright © 2020, Oracle and/or its affiliates43
A curious case from @oradiag
Copyright © 2020, Oracle and/or its affiliates44
CPU Wait on Performance Page is derived not measured
Time model instrumentation:
• Total DB Time
• Total DB CPU
Wait model instrumentation:
• Non-idle wait (I/O and everything else)
CPU Wait: estimating run-queue time
!"# $%&' = )* +&,- − )* !"# + $01+ DB CPU
I/O WAIT
WAIT
DB TIME
CPU Wait
Copyright © 2020, Oracle and/or its affiliates45
Always some “CPU bleed” into measured wait time
• Timestamps
• Call stack traversal
CPU time under wait double-counted
• DB Time
• DB CPU
Shrinking event latencies exacerbate the problem
• May require instrumentation adjustments
CPU under wait
CPUWAIT
CPUWAIT
CPU under wait
Copyright © 2020, Oracle and/or its affiliates46
AWR report from @kevinclosson
• “What’s up with % DB Time greater than 100?”
Close and painful scrutiny revealed CPU under wait
• 50% of I/O wait was CPU time
• AWR1page script developed
Identifying CPU under wait
Top 10 Foreground Events by Total Wait Time
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Total Wait Wait % DB Wait
Event Waits Time (sec) Avg(ms) time Class
------------------------------ ----------- ---------- ---------- ------ --------
db file parallel read 139,819 469.8 3.36 78.1 User I/O
DB CPU 243 40.4
db file sequential read 201,921 52.4 0.26 8.7 User I/O
DB Time << CPU + Wait
47
End
Copyright © 2020, Oracle and/or its affiliates48
@JBeresniewicz
john.beresniewicz@oracle.com
Thank you
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals

More Related Content

What's hot (20)

PDF
Oracle statistics by example
Mauro Pagano
 
PPTX
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Carlos Sierra
 
PDF
Deep review of LMS process
Riyaj Shamsudeen
 
DOC
AWR reports-Measuring CPU
Mohammed Yasir Hashmi
 
PDF
Oracle db performance tuning
Simon Huang
 
PPTX
Oracle sql high performance tuning
Guy Harrison
 
PPTX
Oracle database performance tuning
Yogiji Creations
 
PDF
Understanding oracle rac internals part 1 - slides
Mohamed Farouk
 
PPT
Oracle 10g Performance: chapter 02 aas
Kyle Hailey
 
PPT
Sga internals
sergkosko
 
PDF
Oracle Database performance tuning using oratop
Sandesh Rao
 
PDF
Oracle Active Data Guard: Best Practices and New Features Deep Dive
Glen Hawkins
 
PPSX
Oracle Performance Tuning Fundamentals
Carlos Sierra
 
PPSX
Oracle Performance Tools of the Trade
Carlos Sierra
 
PDF
Migration to Oracle Multitenant
Jitendra Singh
 
PPTX
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
SolarWinds
 
PPTX
Adapting and adopting spm v04
Carlos Sierra
 
PPTX
Data Guard Architecture & Setup
Satishbabu Gunukula
 
PPT
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
John Kanagaraj
 
PPTX
Oracle RAC features on Exadata
Anil Nair
 
Oracle statistics by example
Mauro Pagano
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Carlos Sierra
 
Deep review of LMS process
Riyaj Shamsudeen
 
AWR reports-Measuring CPU
Mohammed Yasir Hashmi
 
Oracle db performance tuning
Simon Huang
 
Oracle sql high performance tuning
Guy Harrison
 
Oracle database performance tuning
Yogiji Creations
 
Understanding oracle rac internals part 1 - slides
Mohamed Farouk
 
Oracle 10g Performance: chapter 02 aas
Kyle Hailey
 
Sga internals
sergkosko
 
Oracle Database performance tuning using oratop
Sandesh Rao
 
Oracle Active Data Guard: Best Practices and New Features Deep Dive
Glen Hawkins
 
Oracle Performance Tuning Fundamentals
Carlos Sierra
 
Oracle Performance Tools of the Trade
Carlos Sierra
 
Migration to Oracle Multitenant
Jitendra Singh
 
Stop the Chaos! Get Real Oracle Performance by Query Tuning Part 1
SolarWinds
 
Adapting and adopting spm v04
Carlos Sierra
 
Data Guard Architecture & Setup
Satishbabu Gunukula
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
John Kanagaraj
 
Oracle RAC features on Exadata
Anil Nair
 

Similar to DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals (20)

PDF
Collaborate 2019 - How to Understand an AWR Report
Alfredo Krieg
 
PDF
Average Active Sessions RMOUG2007
John Beresniewicz
 
PDF
In-memory ColumnStore Index
SolidQ
 
PDF
[D3T1S04] Aurora PostgreSQL performance monitoring and troubleshooting by use...
Amazon Web Services Korea
 
PPTX
Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...
Cloudera, Inc.
 
PPTX
PASS Summit 2020
Kellyn Pot'Vin-Gorman
 
PDF
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Databricks
 
PDF
Spark Summit EU talk by Mike Percy
Spark Summit
 
PPTX
Denver SQL Saturday The Next Frontier
Kellyn Pot'Vin-Gorman
 
PPTX
AWR and ASH Advanced Usage with DB12c
Kellyn Pot'Vin-Gorman
 
PDF
What's New in Apache Hive
DataWorks Summit
 
PDF
MySQL Performance Metrics that Matter
Morgan Tocker
 
PDF
How should I monitor my idaa
Cuneyt Goksu
 
PDF
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
cookie1969
 
PDF
COUG_AAbate_Oracle_Database_12c_New_Features
Alfredo Abate
 
PDF
Challenges of Building a First Class SQL-on-Hadoop Engine
Nicolas Morales
 
PPTX
Copy Data Management for the DBA
Kellyn Pot'Vin-Gorman
 
PDF
Apache Spark for RDBMS Practitioners: How I Learned to Stop Worrying and Lov...
Databricks
 
PDF
Apouc 2014-enterprise-manager-12c
OUGTH Oracle User Group in Thailand
 
PDF
What's New in Apache Hive 3.0?
DataWorks Summit
 
Collaborate 2019 - How to Understand an AWR Report
Alfredo Krieg
 
Average Active Sessions RMOUG2007
John Beresniewicz
 
In-memory ColumnStore Index
SolidQ
 
[D3T1S04] Aurora PostgreSQL performance monitoring and troubleshooting by use...
Amazon Web Services Korea
 
Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...
Cloudera, Inc.
 
PASS Summit 2020
Kellyn Pot'Vin-Gorman
 
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Databricks
 
Spark Summit EU talk by Mike Percy
Spark Summit
 
Denver SQL Saturday The Next Frontier
Kellyn Pot'Vin-Gorman
 
AWR and ASH Advanced Usage with DB12c
Kellyn Pot'Vin-Gorman
 
What's New in Apache Hive
DataWorks Summit
 
MySQL Performance Metrics that Matter
Morgan Tocker
 
How should I monitor my idaa
Cuneyt Goksu
 
pdf-download-db-time-based-oracle-performance-tuning-theory-and.pdf
cookie1969
 
COUG_AAbate_Oracle_Database_12c_New_Features
Alfredo Abate
 
Challenges of Building a First Class SQL-on-Hadoop Engine
Nicolas Morales
 
Copy Data Management for the DBA
Kellyn Pot'Vin-Gorman
 
Apache Spark for RDBMS Practitioners: How I Learned to Stop Worrying and Lov...
Databricks
 
Apouc 2014-enterprise-manager-12c
OUGTH Oracle User Group in Thailand
 
What's New in Apache Hive 3.0?
DataWorks Summit
 
Ad

More from John Beresniewicz (12)

PDF
ASHviz - Dats visualization research experiments using ASH data
John Beresniewicz
 
PDF
NoSQL is Anti-relational
John Beresniewicz
 
PDF
AAS Deeper Meaning
John Beresniewicz
 
PDF
Awr1page OTW2018
John Beresniewicz
 
PDF
Awr1page - Sanity checking time instrumentation in AWR reports
John Beresniewicz
 
PDF
JB Design CV: products / mockups / experiments
John Beresniewicz
 
PDF
Awr1page - Sanity checking time instrumentation in AWR reports
John Beresniewicz
 
PDF
AWR Ambiguity: Performance reasoning when the numbers don't add up
John Beresniewicz
 
PDF
Proactive performance monitoring with adaptive thresholds
John Beresniewicz
 
PDF
Ash Outliers UKOUG2011
John Beresniewicz
 
PDF
Contract-oriented PLSQL Programming
John Beresniewicz
 
PDF
Average Active Sessions - OaktableWorld 2013
John Beresniewicz
 
ASHviz - Dats visualization research experiments using ASH data
John Beresniewicz
 
NoSQL is Anti-relational
John Beresniewicz
 
AAS Deeper Meaning
John Beresniewicz
 
Awr1page OTW2018
John Beresniewicz
 
Awr1page - Sanity checking time instrumentation in AWR reports
John Beresniewicz
 
JB Design CV: products / mockups / experiments
John Beresniewicz
 
Awr1page - Sanity checking time instrumentation in AWR reports
John Beresniewicz
 
AWR Ambiguity: Performance reasoning when the numbers don't add up
John Beresniewicz
 
Proactive performance monitoring with adaptive thresholds
John Beresniewicz
 
Ash Outliers UKOUG2011
John Beresniewicz
 
Contract-oriented PLSQL Programming
John Beresniewicz
 
Average Active Sessions - OaktableWorld 2013
John Beresniewicz
 
Ad

Recently uploaded (20)

PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 

DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals

  • 1. Architect, Enterprise and Cloud Manageability Oracle America John Beresniewicz Know your performance fundamentals DB Time, Average Active Sessions, and ASH Math
  • 2. 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, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation. Safe harbor statement Copyright © 2020, Oracle and/or its affiliates2
  • 3. Copyright © 2020, Oracle and/or its affiliates3 4 3 2 1 Issues ASH Math Average Active Sessions Database Time Agenda
  • 4. Copyright © 2020, Oracle and/or its affiliates | Confidential: Internal/Restricted/Highly Restricted4 Concepts • The core ideas Instrumentation • Services supporting the core ideas Visualization • Presentation of concepts using instrumentation Approach
  • 5. Copyright © 2020, Oracle and/or its affiliates5 Database Time
  • 6. Copyright © 2020, Oracle and/or its affiliates6 Performance is about work and time Performance measures: • Throughput = work / time • Latency (response time) = time / work Database time is about time spent doing database work Database time is the foundation of Diagnostic and Tuning Packs: • ADDM, AWR, SPA, SQL Monitor, EM Perf Page, Top Activity, ASH Analytics Logic of DB Time
  • 7. Copyright © 2020, Oracle and/or its affiliates7 Time spent processing database client calls Specifically: • Foreground time spent executing database calls (SQL) • Actively working (on CPU) or waiting to work (in wait) Note: • Idle wait time is not included in DB Time • Background time is not included in DB Time Definition of DB Time
  • 8. Copyright © 2020, Oracle and/or its affiliates8 DB Time is spent on CPU or in wait DB Time clock starts upon client call to DB and stops with response to client Model of DB Time CPU WAIT DB TIME
  • 9. Copyright © 2020, Oracle and/or its affiliates9 Timers built into code path to measure DB Time spent in certain operations: • Call begin/exit (total time in call) • Parsing • PL/SQL compilation CPU time fetched from OS Can be tricky given call stack complexity • V$SYS_TIME_MODEL • DBA_HIST_SYS_TIME_MODEL • V$SYSMETRIC_HISTORY Instrumentation: Time Model
  • 10. Copyright © 2020, Oracle and/or its affiliates10 The following are critical Time Model measures: DB Time • Clearest and coarsest instrumentation points, highly reliable • Includes run-queue time on CPU saturated systems DB CPU • Fetched from OS counters by foregrounds • Includes only actual time on CPU, not time on run-queue Also: • background cpu time • background elapsed Critical Measures
  • 11. Copyright © 2020, Oracle and/or its affiliates11 DB call execution involves many queueing, serialization, and synchronization mechanisms • Locks, latches, mutexes • Cores / CPUs / instance caging External I/O DB code is instrumented to time these “wait events” • V$WAITCLASSMETRIC_HISTORY (???) • V$EVENT_HISTOGRAM Instrumentation: Wait Model DB CPU WAITUser I/O WAIT DB Time
  • 12. Copyright © 2020, Oracle and/or its affiliates12 CPU saturation is an apex problem • Processing capacity exhausted, no more work can be done Instrumentation distortion • Wait event timing • Invisible / missing DB Time Visibility issues, difficult to measure Run queue: silent killer
  • 13. Copyright © 2020, Oracle and/or its affiliates13 Run-queue distortion: wait path DB file scattered read Run queue CPU actual event latency measured event latency 1. Event finishes and foreground queues for CPU 2. End of wait timestamp requires CPU 3. Measured event latency includes run-queue time end timestampbegin timestamp
  • 14. Copyright © 2020, Oracle and/or its affiliates14 DB Time exceeds total DB CPU time under CPU saturation Run-queue not always reliably measured • Check V$OSSTAT.STAT_NAME = ’RSRC_MGR_CPU_WAIT_TIME’ Run-queue distortion: CPU path CPU Run queue CPU DB Time DB CPU DB CPU
  • 15. Copyright © 2020, Oracle and/or its affiliates15 Quantifying true CPU capacity increasingly difficult • Hyper-threading • Virtualization and hypervisors • Containers and cloud Core utilization is the used fraction of raw core time available • When < 1 system is not CPU saturated • When > 1 system exceeding raw core capacity through hyper-threading Core Utilization !" #$% + '()*+,-./0 )1. 23(1420 5672 ∗ )-,2 )-./5
  • 16. Copyright © 2020, Oracle and/or its affiliates16 Viz: EM DB Performance Page
  • 17. Copyright © 2020, Oracle and/or its affiliates17 Average Active Sessions
  • 18. Copyright © 2020, Oracle and/or its affiliates18 Labeling the Perf Page chart DB Time per sec = “Centi-users per second”?
  • 19. Copyright © 2020, Oracle and/or its affiliates19 Over some time interval, e.g. an AWR snapshot AAS is the rate at which DB Time is accumulates in the system We also think of AAS as the load on the database Typically, total sessions >> AAS (due to session idle time) • However poor session management is a classic performance pitfall Definition of AAS !"#$%&# !'()"# *#++),-+ = !!* = /01 2)3# #4%5+#6 ()3#
  • 20. Copyright © 2020, Oracle and/or its affiliates20 AAS = rate of change of DB Time over time Integrating AAS = computing DB Time Perf Page is literally a picture of DB Time AAS and DB Time !"#$%& '&''$()' # = + ,- .$/& +# 0 12 13 !"#$%& '&''$()' # +# = ,- .$/& #2 #1
  • 21. Copyright © 2020, Oracle and/or its affiliates21 AAS for comparisons: • Across time periods – how does load vary? • Across similar systems – which DB is busiest? Per-core normalization • Compare different systems’ profiles • AWR1page script Normalization and AAS !""#(%&'() *+,- *+./( !""#(012) *+,- *+./(
  • 22. Copyright © 2020, Oracle and/or its affiliates22 Q: Whose time is DB Time? A: Business entities using database services to accomplish time-bound goals • Interactive end-users • Automated business processes ”Enterprise time” is the same regardless of which database or service is being invoked • One second spent waiting for DB1 response is no different than one waiting for DB2 Enterprise DB Time can be thought of as a fungible quantity Fungibility of DB Time
  • 23. Copyright © 2020, Oracle and/or its affiliates23 Viz: EM Enterprise Loadmap
  • 24. Copyright © 2020, Oracle and/or its affiliates27 Active session state sampled into memory every second (1000 msec) • Active = in DB call and not in idle wait Fixes-up values unknown at sampling time • TIME_WAITED Sampled session state is either ON CPU or in WAIT event • Session in WAIT is known • Session presumed ON CPU if not in WAIT Wait event samples biased toward longer latency waits Mechanism design is latch-less, efficient, reliable Instrumentation: Active Session History Conforms to the model of DB Time
  • 25. Copyright © 2020, Oracle and/or its affiliates28 Viz: EM Top Activity Page
  • 26. Copyright © 2020, Oracle and/or its affiliates |29 ASH Math
  • 27. Copyright © 2020, Oracle and/or its affiliates30 Decompose DB Time by aggregating ASH sample rows • Grouped over dimensions, classic fact table query • Many analysis columns: 30+ in DB 10.2, 110+ in DB 12.2 Filter and Aggregate to isolate and expose how DB Time is spent Normalize to AAS: divide DB Time by aggregation interval time Estimating DB Time using ASH !"#$% ∗ = () *+,- (/-0/) select trunc(sample_time,'MI’), sql_id ,sum(usecs_per_row)/(60*power(10,6)) as AAS from v$active_session_history group by trunc(sample_time,'MI’), sql_id;
  • 28. Copyright © 2020, Oracle and/or its affiliates31 Summing samples is equivalent to computing Riemann estimate of DB Time integral • !"#$% &'( )*+,-./ = *!%12.'.))1"$) % • ∆% = )*+,-1$4 1$%.52*- = 1 ).! The calculus of ASH Math ∆% ASH Sample count time sessions *!%12.'.))1"$) %
  • 29. Copyright © 2020, Oracle and/or its affiliates32 Both are literal pictures of DB Time: • Perf Page is top-down instrumentation: • Time Model & Wait model • Top Activity is bottom-up instrumentation • ASH It’s the Fundamental Theorem of Calculus! Perf Page ≡ Top Activity Page
  • 30. Copyright © 2020, Oracle and/or its affiliates33 Beware: the ASH sampler is biased toward longer latencies • Higher probability of being sampled Common mistakes: • AVG(TIME_WAITED) ≠ average event latency • SUM(TIME_WAITED) ≠ DB wait time Bad ASH math
  • 31. Copyright © 2020, Oracle and/or its affiliates34 Viz: ASH Analytics Loadmap
  • 32. IN_CONNECTION_MGMT VARCHAR2(1) IN_PARSE VARCHAR2(1) IN_HARD_PARSE VARCHAR2(1) IN_PLSQL_RPC VARCHAR2(1) IN_PLSQL_COMPILATION VARCHAR2(1) IN_JAVA_EXECUTION VARCHAR2(1) IN_BIND VARCHAR2(1) Copyright © 2020, Oracle and/or its affiliates35 ASH math can estimate DB Time spent in “un-timeable” operations 1. Timestamping may be relatively expensive for very low latency operations 2. Instead, set a session state bit ON when operation begins – very cheap 3. When operations completes, set the bit OFF 4. ASH sampler samples bit vector 5. Using ASH math: COUNT(samples with bit ON) = DB Time in operation Bit vector magic
  • 33. Copyright © 2020, Oracle and/or its affiliates36 So what can TIME_WAITED tell us? Recall: ASH sampling is independent of session activity and on strict schedule TIME_WAITED: advanced ASH math time wait event E CPUCPU 1000 ms 200 ms ASH Sample time Pr # $%&'()* = ,-./#_12.-#3 4%&'(567 .68)9:%(
  • 34. Copyright © 2020, Oracle and/or its affiliates37 • Questions: • If a sampled 200 msec event counts for 1000 msec of DB Time, what about the other 800 msec? • How can the likelihood of sampling an event provide an estimate for how often it occurs? Estimated number of occurrences is number required to minimally cover sampling interval TIME_WAITED: estimating event counts !"#_%&'(#)*)+, = GREATEST 456789:; 9:<=>?58 #@A!_BC@#!D , 1 1000 ms 200 ms time wait event E wait event E wait event E wait event E wait event E
  • 35. Copyright © 2020, Oracle and/or its affiliates38 Estimating average latency properly select wait_class ,TRUNC(DBtime_usecs / est_count) as AvgLatency_usec ,TRUNC(bad_ash_math) as bad_ash_math from (select wait_class ,SUM(GREATEST(usecs_per_row / time_waited, 1)) est_count ,SUM(usecs_per_row) DBtime_usecs ,AVG(time_waited) bad_ash_math from v$active_session_history where time_waited > 0 group by wait_class )
  • 36. Copyright © 2020, Oracle and/or its affiliates39 Bad ASH math vs. properly estimated average latencies: Results WAIT_CLASS AVGLATENCY_USEC BAD_ASH_MATH Concurrency 702 21139 User I/O 735 18380 Administrative 104910 135946 System I/O 543 855 Other 71 65951 Scheduler 9883 10901 Configuration 254143 330538 Cluster 155 5632 Application 277 26880 Commit 494 927 Network 399 51402 Idle 1004 1006
  • 37. Copyright © 2020, Oracle and/or its affiliates40 Issues
  • 38. Copyright © 2020, Oracle and/or its affiliates Database is only one of many layers in the Enterprise technology stack Determine how much DB Time contributes to total Enterprise time Beware of instrumentation infatuation DB Time is not the only relevant time Database Storage Client Services Micro services Database Storage response time profile
  • 39. Copyright © 2020, Oracle and/or its affiliates42 Principal Database Engineer, AWS Kevin Closson “Everything is a CPU problem”
  • 40. Copyright © 2020, Oracle and/or its affiliates43 A curious case from @oradiag
  • 41. Copyright © 2020, Oracle and/or its affiliates44 CPU Wait on Performance Page is derived not measured Time model instrumentation: • Total DB Time • Total DB CPU Wait model instrumentation: • Non-idle wait (I/O and everything else) CPU Wait: estimating run-queue time !"# $%&' = )* +&,- − )* !"# + $01+ DB CPU I/O WAIT WAIT DB TIME CPU Wait
  • 42. Copyright © 2020, Oracle and/or its affiliates45 Always some “CPU bleed” into measured wait time • Timestamps • Call stack traversal CPU time under wait double-counted • DB Time • DB CPU Shrinking event latencies exacerbate the problem • May require instrumentation adjustments CPU under wait CPUWAIT CPUWAIT CPU under wait
  • 43. Copyright © 2020, Oracle and/or its affiliates46 AWR report from @kevinclosson • “What’s up with % DB Time greater than 100?” Close and painful scrutiny revealed CPU under wait • 50% of I/O wait was CPU time • AWR1page script developed Identifying CPU under wait Top 10 Foreground Events by Total Wait Time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Total Wait Wait % DB Wait Event Waits Time (sec) Avg(ms) time Class ------------------------------ ----------- ---------- ---------- ------ -------- db file parallel read 139,819 469.8 3.36 78.1 User I/O DB CPU 243 40.4 db file sequential read 201,921 52.4 0.26 8.7 User I/O DB Time << CPU + Wait
  • 45. Copyright © 2020, Oracle and/or its affiliates48 @JBeresniewicz [email protected] Thank you