MMON Sampling ASH Data

Doug's Oracle Blog

  • Home
  • Papers
  • Books
  • C.V.
  • Fun
  • Oracle Blog
  • Personal Blog

Apr 17: MMON Sampling ASH Data

When I was working on the course, I noticed this White Paper (PDF) on Oracle 10g Self-Management Framework Internals: Exploring the Automatic Workload Repository. The paper describes the way that MMON selects 1 in 10 of the ASH samples for storage in DBA_HIST_ACTIVE_SESS_HISTORY (I suppose it would be more correct to say WRH$_ACTIVE_SESSION_HISTORY_BL) :-

"The in-memory data that is selected for writing is randomly chosen (sampling of the samples)."

This phrase confused me but, rather than digging around to resolve it (it was late), I took the paper at face value and repeated the phrase during the class the next day. Someone questioned it (as I said before, they were a smart bunch) and I found myself unable to justify it, particularly as it didn't really make sense to me either. So that evening I sent a mail to a couple of people who would know and, as well as getting a quick answer, was able to sit back and enjoy a debate about whether the selection could be described as 'random' or not. The answer first :-
Not random, think MOD(sample_id, 10)

Initially I thought that meant that MMON selects every tenth sample from the ASH buffers*. That would be the case if the sample_id was incremented every time there was data in a sample but it's incremented even if there are no active sessions. For example, here is a selection of ASH samples from an active system. (Note that a 'sample' includes all of the sessions that were Active at the sample point, so the volume of data and number of sessions in each sample will vary.)

SYS@TEST1020> SELECT sample_id, TO_CHAR(sample_time, 'HH24:MI:SS'), COUNT(*)
  2  FROM v$active_session_history
  3  WHERE sample_id > 1238065
  4  GROUP BY sample_id, TO_CHAR(sample_time, 'HH24:MI:SS')
  5  ORDER BY 1
  6  /

 SAMPLE_ID TO_CHAR(   COUNT(*)
---------- -------- ----------
   1238073 20:57:17          1
   1238074 20:57:18          2

Straightforward so far; there was one active session at 20:57:17 and two at 20:57:18. So let's look at the next bunch of samples that appear in the output.

   1238162 20:58:47          1
   1238242 21:00:08          1
   1238245 21:00:11          1
   1238266 21:00:32          1
   1238278 21:00:45          1
   1238286 21:00:53          1
   1238358 21:02:06          1
   1238371 21:02:19          2
   1238483 21:04:12          1
   1238510 21:04:40          1
   1238527 21:04:57          1
   1238554 21:05:24          1
   1238560 21:05:31          1
   1238563 21:05:34          1
   1238575 21:05:46          1
   1238667 21:07:19          1

Because there were no active sessions between 20:57:19 and 20:58:46, there's no ASH data (as expected), but SAMPLE_ID is incremented every second. If we apply MOD(SAMPLE_ID) to determine which samples should be written to the workload repository, we'd end up with something like this.

   1238073 20:57:17          1
   1238074 20:57:18          2
   1238162 20:58:47          1
   1238242 21:00:08          1
   1238245 21:00:11          1
   1238266 21:00:32          1
   1238278 21:00:45          1
   1238286 21:00:53          1
   1238358 21:02:06          1
   1238371 21:02:19          2
   1238483 21:04:12          1
   1238510 21:04:40          1 << IN AWR   
   1238527 21:04:57          1
   1238554 21:05:24          1
   1238560 21:05:31          1 << IN AWR   
   1238563 21:05:34          1
   1238575 21:05:46          1
   1238667 21:07:19          1

I can check this by forcing a manual AWR snapshot.

SYS@TEST1020> exec dbms_workload_repository.create_snapshot

PL/SQL procedure successfully completed.

SYS@TEST1020> SELECT ash.sample_id, TO_CHAR(ash.sample_time, 'HH24:MI:SS'),
  2     DECODE(awr.sample_id, NULL, 'NO', 'YES') in_awr
  3  FROM v$active_session_history ash, dba_hist_active_sess_history awr
  4  WHERE ash.sample_id=awr.sample_id  (+)
  5  AND ash.sample_id > 1238065
  6  GROUP BY ash.sample_id, TO_CHAR(ash.sample_time, 'HH24:MI:SS'),
  7     DECODE(awr.sample_id, NULL, 'NO', 'YES')
  8  ORDER BY 2;

 SAMPLE_ID TO_CHAR( IN_
---------- -------- ---
   1238073 20:57:17 NO
   1238074 20:57:18 NO
   1238162 20:58:47 NO
   1238242 21:00:08 NO
   1238245 21:00:11 NO
   1238266 21:00:32 NO
   1238278 21:00:45 NO
   1238286 21:00:53 NO
   1238358 21:02:06 NO
   1238371 21:02:19 NO
   1238483 21:04:12 NO
   1238510 21:04:40 YES
   1238527 21:04:57 NO
   1238554 21:05:24 NO
   1238560 21:05:31 YES
   1238563 21:05:34 NO
   1238575 21:05:46 NO
   1238667 21:07:19 NO

Bear in mind that this is on a very quiet instance running on my laptop so it's possible to get large holes in the AWR data. The reality is that any reasonably busy system is likely to have ASH data for every second and so will have an AWR sample for every ten seconds.

As for the debate, I'm no mathematician, but although the sample time gaps in DBA_HIST_ACTIVE_SESS_HISTORY might appear random in isolation, it seems clear to me that they aren't. I think the term 'sampling of the samples' is perfect, though.

* I suppose it does select every tenth sample really, but there might be no data there.
Posted by Doug Burns Comments: (4) Trackbacks: (0)
Defined tags for this entry: ash, awr
Related entries by tags:
Network Events in ASH
Alternative Pictures Demo
That Pictures demo in full
Diagnosing Locking Problems using ASH/LogMiner – The End
Diagnosing Locking Problems using ASH/LogMiner – Part 9
Diagnosing Locking Problems using ASH/LogMiner – Part 8
Diagnosing Locking Problems using ASH/LogMiner – Part 7
Diagnosing Locking Problems using ASH – Part 6
Diagnosing Locking Problems using ASH – Part 5
Diagnosing Locking Problems using ASH – Part 4

Trackbacks
Trackback specific URI for this entry

No Trackbacks

Comments
Display comments as (Linear | Threaded)

#1 - Virag Sharma said:
2008-05-16 06:09 - (Reply)

1) Filter ratio can be changed using parameter _ash_disk_filter_ratio (default is 10 i.e. one out of 10 sample)

2) ASH not do sampling for each connect session

_ash_sample_all = false ( detault )

3) If in memory ASH full more then 66 % , it flush ASH data. That make more randomly chosen samples

#1.1 - Doug Burns said:
2008-05-16 06:32 - (Reply)

As described here?

#2 - Tyler D Muth said:
2011-06-22 14:09 - (Reply)

FYI, the link to the Oracle White Paper has changed to:
http://www.oracle.com/technetwork/database/focus-areas/manageability/ps-s001-274001-106-1-fin-v1-133763.pdf

#2.1 - Doug Burns said:
2011-06-24 10:23 - (Reply)

Thanks Tyler - fixed!


Add Comment

Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
BBCode format allowed
 
 

Statistics on Partitioned Tables

Contents

Part 1 - Default options - GLOBAL AND PARTITION
Part 2 - Estimated Global Stats
Part 3 - Stats Aggregation Problems I
Part 4 - Stats Aggregation Problems II
Part 5 - Minimal Stats Aggregation
Part 6a - COPY_TABLE_STATS - Intro
Part 6b - COPY_TABLE_STATS - Mistakes
Part 6c - COPY_TABLE_STATS - Bugs and Patches
Part 6d - COPY_TABLE_STATS - A Light-bulb Moment
Part 6e - COPY_TABLE_STATS - Bug 10268597

Comments

Doug Burns about 10053 Trace Files - Different Plan in Different Environments
Tue, 02.04.2013 08:57
You're welcome. Now I just nee d to pull my finger out and ac tually come up [...]
Howard Rogers about 10053 Trace Files - Different Plan in Different Environments
Mon, 01.04.2013 23:08
Makes a big difference, so tha nks for that! With two brow ser windows, o [...]
stelioscharalambides.com about 10053 Trace Files
Sat, 30.03.2013 16:28

Upcoming Presentations

Bookmark

Open All | Close All

Syndicate This Blog

  • XML RSS 2.0 feed
  • ATOM/XML ATOM 1.0 feed
  • XML RSS 2.0 Comments
  • Feedburner Feed

Powered by

Serendipity PHP Weblog

Show tagged entries

xml 11g
xml ACE
xml adaptive thresholds
xml ASH
xml Audit Vault
xml AWR
xml Blogging
xml conferences
xml Cuddly Toys
xml Database Refresh
xml DBMS_STATS
xml Direct Path Reads
xml Fun
xml grid control
xml hotsos 2010
xml listener
xml Locking
xml oow
xml oow2009
xml optimiser
xml OTN
xml Parallel
xml Partitions
xml Patching
xml swingbench
xml The Reality Gap
xml time matters
xml ukoug
xml ukoug2009
xml Unix/Shell
xml Useful Links

Disclaimer

For the avoidance of any doubt, all views expressed here are my own and not those of past or current employers, clients, friends, Oracle Corporation, my Mum or, indeed, Flatcat. If you want to sue someone, I suggest you pick on Tigger, but I hope you have a good lawyer. Frankly, I doubt any of the former agree with my views or would want to be associated with them in any way.

Design by Andreas Viklund | Conversion to s9y by Carl