<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SQL ASH timings III</title>
	<atom:link href="/2011/05/06/sql-ash-timings-iii/feed/" rel="self" type="application/rss+xml" />
	<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/</link>
	<description>database performance, SQL tuning and data visualizatoin</description>
	<lastBuildDate>Sat, 03 Mar 2018 05:02:37 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6</generator>
	<item>
		<title>By: http://dboptimizer.com/tools-2/ &#124; xfang</title>
		<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/#comment-11355</link>
		<dc:creator>http://dboptimizer.com/tools-2/ &#124; xfang</dc:creator>
		<pubDate>Fri, 28 Dec 2012 14:29:04 +0000</pubDate>
		<guid isPermaLink="false">http://dboptimizer.com/?p=811#comment-11355</guid>
		<description><![CDATA[[...] http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/ [...]]]></description>
		<content:encoded><![CDATA[<p>[...] <a href="/2011/05/06/sql-ash-timings-iii/" rel="nofollow">http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle Hailey</title>
		<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/#comment-8804</link>
		<dc:creator>Kyle Hailey</dc:creator>
		<pubDate>Tue, 14 Aug 2012 17:30:34 +0000</pubDate>
		<guid isPermaLink="false">http://dboptimizer.com/?p=811#comment-8804</guid>
		<description><![CDATA[@Jigar,
   Good idea to document the parts of the query.
   The (3600*24) is seconds in a day and when subtracting two dates the value you get is the number of days so seconds in a day multiplied by the difference of two dates is the elapsed time between the two dates in seconds.
   The &quot;having round(max(delta,0) &gt; 300&quot; looks for queries that ran for more than 5 minutes, ie those queries that were found to have a sample time in ASH greater than 300 seconds higher than the start time of the execution of the query, and 300 seconds if 5 minutes.Could have picked any number instead of 300, but the query was stated as, &quot;find all sql statements that took longer than 5 minutes.]]></description>
		<content:encoded><![CDATA[<p>@Jigar,<br />
   Good idea to document the parts of the query.<br />
   The (3600*24) is seconds in a day and when subtracting two dates the value you get is the number of days so seconds in a day multiplied by the difference of two dates is the elapsed time between the two dates in seconds.<br />
   The &#8220;having round(max(delta,0) > 300&#8243; looks for queries that ran for more than 5 minutes, ie those queries that were found to have a sample time in ASH greater than 300 seconds higher than the start time of the execution of the query, and 300 seconds if 5 minutes.Could have picked any number instead of 300, but the query was stated as, &#8220;find all sql statements that took longer than 5 minutes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jigar</title>
		<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/#comment-8778</link>
		<dc:creator>jigar</dc:creator>
		<pubDate>Fri, 10 Aug 2012 17:54:34 +0000</pubDate>
		<guid isPermaLink="false">http://dboptimizer.com/?p=811#comment-8778</guid>
		<description><![CDATA[&lt;a href=&quot;#comment-901&quot; rel=&quot;nofollow&quot;&gt;@Sandro&lt;/a&gt; 

Hi sandro, ran into your query/ can you make some sense of these values?
(3600*24) delta
and
having round(max(delta),0) &gt; 300]]></description>
		<content:encoded><![CDATA[<p><a href="#comment-901" rel="nofollow">@Sandro</a> </p>
<p>Hi sandro, ran into your query/ can you make some sense of these values?<br />
(3600*24) delta<br />
and<br />
having round(max(delta),0) &gt; 300</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle Hailey</title>
		<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/#comment-902</link>
		<dc:creator>Kyle Hailey</dc:creator>
		<pubDate>Thu, 24 Nov 2011 19:22:57 +0000</pubDate>
		<guid isPermaLink="false">http://dboptimizer.com/?p=811#comment-902</guid>
		<description><![CDATA[Updated my comment above yours with the correction. Thanks]]></description>
		<content:encoded><![CDATA[<p>Updated my comment above yours with the correction. Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sandro</title>
		<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/#comment-901</link>
		<dc:creator>Sandro</dc:creator>
		<pubDate>Thu, 24 Nov 2011 18:10:19 +0000</pubDate>
		<guid isPermaLink="false">http://dboptimizer.com/?p=811#comment-901</guid>
		<description><![CDATA[Your query &quot;how can I find queries that run longer than 5 minutes&quot; is incorrect. This is corrected version.

select
   sql_id,
   count(*),
   round(min(delta),0) mn,
   round(avg(delta),0) av,
   round(max(delta),0) mx,
   substr(max(times),12) max_run_time
from (
   select
        sql_id,
        sql_exec_id,
        max(delta) delta ,
        -- lpad sets a fixed width on delta so it can be
        -- stripped off above with substr
        -- delta in &quot;times&quot; is just for sorting not displaying
        lpad(round(max(delta),0),10) &#124;&#124; &#039; &#039; &#124;&#124;
        to_char(min(start_time),&#039;YY-MM-DD HH24:MI:SS&#039;)  &#124;&#124; &#039; &#039; &#124;&#124;
        to_char(max(end_time),&#039;YY-MM-DD HH24:MI:SS&#039;)  times
   from ( select
                                            sql_id,
                                            sql_exec_id,
              cast(sample_time as date)     end_time,
              cast(sql_exec_start as date)  start_time,
              ((cast(sample_time    as date)) -
               (cast(sql_exec_start as date))) * (3600*24) delta
           from
              dba_hist_active_sess_history
           where sql_exec_id is not null
        )
   group by sql_id,sql_exec_id
)
group by sql_id
having round(max(delta),0) &gt; 300
order by mx
/]]></description>
		<content:encoded><![CDATA[<p>Your query &#8220;how can I find queries that run longer than 5 minutes&#8221; is incorrect. This is corrected version.</p>
<p>select<br />
   sql_id,<br />
   count(*),<br />
   round(min(delta),0) mn,<br />
   round(avg(delta),0) av,<br />
   round(max(delta),0) mx,<br />
   substr(max(times),12) max_run_time<br />
from (<br />
   select<br />
        sql_id,<br />
        sql_exec_id,<br />
        max(delta) delta ,<br />
        &#8212; lpad sets a fixed width on delta so it can be<br />
        &#8212; stripped off above with substr<br />
        &#8212; delta in &#8220;times&#8221; is just for sorting not displaying<br />
        lpad(round(max(delta),0),10) || &#8216; &#8216; ||<br />
        to_char(min(start_time),&#8217;YY-MM-DD HH24:MI:SS&#8217;)  || &#8216; &#8216; ||<br />
        to_char(max(end_time),&#8217;YY-MM-DD HH24:MI:SS&#8217;)  times<br />
   from ( select<br />
                                            sql_id,<br />
                                            sql_exec_id,<br />
              cast(sample_time as date)     end_time,<br />
              cast(sql_exec_start as date)  start_time,<br />
              ((cast(sample_time    as date)) -<br />
               (cast(sql_exec_start as date))) * (3600*24) delta<br />
           from<br />
              dba_hist_active_sess_history<br />
           where sql_exec_id is not null<br />
        )<br />
   group by sql_id,sql_exec_id<br />
)<br />
group by sql_id<br />
having round(max(delta),0) &gt; 300<br />
order by mx<br />
/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle Hailey</title>
		<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/#comment-830</link>
		<dc:creator>Kyle Hailey</dc:creator>
		<pubDate>Tue, 08 Nov 2011 06:07:04 +0000</pubDate>
		<guid isPermaLink="false">http://dboptimizer.com/?p=811#comment-830</guid>
		<description><![CDATA[another query - get the CPU, IO and WAIT for sql_ids from dba_hist, ie an AWR repository:
&lt;pre&gt;
select
     SQL_ID ,
     sum(decode(session_state,&#039;ON CPU&#039;,1,0))     &quot;CPU&quot;,
     sum(decode(session_state,&#039;WAITING&#039;,1,0))    -
     sum(decode(session_state,&#039;WAITING&#039;, decode(wait_class, &#039;User I/O&#039;,1,0),0))    &quot;WAIT&quot; ,
     sum(decode(session_state,&#039;WAITING&#039;, decode(wait_class, &#039;User I/O&#039;,1,0),0))    &quot;IO&quot; ,
     sum(decode(session_state,&#039;ON CPU&#039;,1,1))     &quot;TOTAL&quot;
from   dba_hist_active_sess_history 
where SQL_ID is not NULL  
 and  dbid=&amp;dbid
   -- and sample_time between 
   --     to_date(&#039;07-NOV-2011 16:00&#039;,&#039;DD-MON-YYYY HH24:MI&#039;) and
   --     to_date(&#039;07-NOV-2011 17:00&#039;,&#039;DD-MON-YYYY HH24:MI&#039;) 
group by sql_id
order by sum(decode(session_state,&#039;ON CPU&#039;,1,1))   desc
/
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>another query &#8211; get the CPU, IO and WAIT for sql_ids from dba_hist, ie an AWR repository:</p>
<pre>
select
     SQL_ID ,
     sum(decode(session_state,'ON CPU',1,0))     "CPU",
     sum(decode(session_state,'WAITING',1,0))    -
     sum(decode(session_state,'WAITING', decode(wait_class, 'User I/O',1,0),0))    "WAIT" ,
     sum(decode(session_state,'WAITING', decode(wait_class, 'User I/O',1,0),0))    "IO" ,
     sum(decode(session_state,'ON CPU',1,1))     "TOTAL"
from   dba_hist_active_sess_history 
where SQL_ID is not NULL  
 and  dbid=&#038;dbid
   -- and sample_time between 
   --     to_date('07-NOV-2011 16:00','DD-MON-YYYY HH24:MI') and
   --     to_date('07-NOV-2011 17:00','DD-MON-YYYY HH24:MI') 
group by sql_id
order by sum(decode(session_state,'ON CPU',1,1))   desc
/
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle Hailey</title>
		<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/#comment-461</link>
		<dc:creator>Kyle Hailey</dc:creator>
		<pubDate>Wed, 20 Jul 2011 18:36:17 +0000</pubDate>
		<guid isPermaLink="false">http://dboptimizer.com/?p=811#comment-461</guid>
		<description><![CDATA[question: how can I find queries that run longer than 5 minutes:
&lt;pre&gt;
col av for 9999999
col mx for 9999999
col mn for 9999999
 
select
   sql_id,
   count(*),
   round(min(delta),0) mn,
   round(avg(delta),0) av,
   round(max(delta),0) mx,
   substr(max(times),12) max_run_time
from (
   select
        sql_id,
        sql_exec_id,
        max(delta) delta ,
        -- lpad sets a fixed width on delta so it can be
        -- stripped off above with substr
        -- delta in &quot;times&quot; is just for sorting not displaying
        lpad(round(max(delta),0),10) &#124;&#124; &#039; &#039; &#124;&#124;
        to_char(min(start_time),&#039;YY-MM-DD HH24:MI:SS&#039;)  &#124;&#124; &#039; &#039; &#124;&#124;
        to_char(max(end_time),&#039;YY-MM-DD HH24:MI:SS&#039;)  times
   from ( select
                                            sql_id,
                                            sql_exec_id,
              cast(sample_time as date)     end_time,
              cast(sql_exec_start as date)  start_time,
              ((cast(sample_time    as date)) -
               (cast(sql_exec_start as date))) * (3600*24) delta
 
           from
              dba_hist_active_sess_history
           where sql_exec_id is not null
        )
   group by sql_id,sql_exec_id
 
)
group by sql_id
-- incorrectly was
-- having mx &gt; 300
-- this is the right syntax
having round(max(delta),0) &gt; 300
order by mx
/
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>question: how can I find queries that run longer than 5 minutes:</p>
<pre>
col av for 9999999
col mx for 9999999
col mn for 9999999
 
select
   sql_id,
   count(*),
   round(min(delta),0) mn,
   round(avg(delta),0) av,
   round(max(delta),0) mx,
   substr(max(times),12) max_run_time
from (
   select
        sql_id,
        sql_exec_id,
        max(delta) delta ,
        -- lpad sets a fixed width on delta so it can be
        -- stripped off above with substr
        -- delta in "times" is just for sorting not displaying
        lpad(round(max(delta),0),10) || ' ' ||
        to_char(min(start_time),'YY-MM-DD HH24:MI:SS')  || ' ' ||
        to_char(max(end_time),'YY-MM-DD HH24:MI:SS')  times
   from ( select
                                            sql_id,
                                            sql_exec_id,
              cast(sample_time as date)     end_time,
              cast(sql_exec_start as date)  start_time,
              ((cast(sample_time    as date)) -
               (cast(sql_exec_start as date))) * (3600*24) delta
 
           from
              dba_hist_active_sess_history
           where sql_exec_id is not null
        )
   group by sql_id,sql_exec_id
 
)
group by sql_id
-- incorrectly was
-- having mx > 300
-- this is the right syntax
having round(max(delta),0) > 300
order by mx
/
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: DB Optimizer &#187; SQL execution times from ASH</title>
		<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/#comment-320</link>
		<dc:creator>DB Optimizer &#187; SQL execution times from ASH</dc:creator>
		<pubDate>Thu, 19 May 2011 04:07:53 +0000</pubDate>
		<guid isPermaLink="false">http://dboptimizer.com/?p=811#comment-320</guid>
		<description><![CDATA[[...] http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/ [...]]]></description>
		<content:encoded><![CDATA[<p>[...] <a href="/2011/05/06/sql-ash-timings-iii/" rel="nofollow">http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle Hailey</title>
		<link>http://dboptimizer.com/2011/05/06/sql-ash-timings-iii/#comment-317</link>
		<dc:creator>Kyle Hailey</dc:creator>
		<pubDate>Thu, 19 May 2011 01:17:51 +0000</pubDate>
		<guid isPermaLink="false">http://dboptimizer.com/?p=811#comment-317</guid>
		<description><![CDATA[&gt;&gt; Thanks for the great posts on this topic.
&gt;&gt; I didn’t realize that sql_exec_id had been added to
&gt;&gt; dba_hist_active_sess_history. We have some queries with
&gt;&gt; skewed and this will give us some insight into the variation
&gt;&gt; in execution times for those queries. We had a question about
&gt;&gt; the values that you are passing to width_bucket(). You are
&gt;&gt; passing 0 and mxdelta+.1 for the min_value and max_value parameters,
&gt;&gt; respectively. That results in very skewed histograms in your
&gt;&gt; examples. (There’s 1 row where there aren’t any values in
&gt;&gt; the 1st histogram.) Is there any reason why you are passing
&gt;&gt; those values instead of mndelta and mxdelta?

Good questions. One is easier than the other

1) Why did I use 0 for the min bucket? It was the easiest quickest thing to put for minimum value. A better value would have been the min value ever seen for that query as the starting bucket. I thought about this but never got around to it.

2) Why did I pass in mxdelta+.1 for the max bucket? Well this is a bit of hack that I didn’t look into closely but at least meant to document but forgot to.
With width_bucket, if I ask for 5 buckets I get 2 extra for a total of 7.
The bottom is anything below my minimum, which in this case will always have 0 values as no query should have a negative response time, so I can ignore this bucket. The largest will be anything starting with my largest value on up so if I add a tiny bit to my max value, then this bucket never have values and always be 0 so I can ignore it and I’m back to my 5 buckets.
What if I just asked for 4 buckets instead? Wouldn’t this work? This would give me 6 buckets and I could ignore the first giving me 5 buckets, right?
If I asked for 4 buckets then the fifth bucket would only have single max values in it , ie no range. For the most part this bucket will just have the value 1, unless the exact maximum elapsed time happened more than once. I’d prefer the 5th bucket to actually show a range rather than a single value.]]></description>
		<content:encoded><![CDATA[<p>>> Thanks for the great posts on this topic.<br />
>> I didn’t realize that sql_exec_id had been added to<br />
>> dba_hist_active_sess_history. We have some queries with<br />
>> skewed and this will give us some insight into the variation<br />
>> in execution times for those queries. We had a question about<br />
>> the values that you are passing to width_bucket(). You are<br />
>> passing 0 and mxdelta+.1 for the min_value and max_value parameters,<br />
>> respectively. That results in very skewed histograms in your<br />
>> examples. (There’s 1 row where there aren’t any values in<br />
>> the 1st histogram.) Is there any reason why you are passing<br />
>> those values instead of mndelta and mxdelta?</p>
<p>Good questions. One is easier than the other</p>
<p>1) Why did I use 0 for the min bucket? It was the easiest quickest thing to put for minimum value. A better value would have been the min value ever seen for that query as the starting bucket. I thought about this but never got around to it.</p>
<p>2) Why did I pass in mxdelta+.1 for the max bucket? Well this is a bit of hack that I didn’t look into closely but at least meant to document but forgot to.<br />
With width_bucket, if I ask for 5 buckets I get 2 extra for a total of 7.<br />
The bottom is anything below my minimum, which in this case will always have 0 values as no query should have a negative response time, so I can ignore this bucket. The largest will be anything starting with my largest value on up so if I add a tiny bit to my max value, then this bucket never have values and always be 0 so I can ignore it and I’m back to my 5 buckets.<br />
What if I just asked for 4 buckets instead? Wouldn’t this work? This would give me 6 buckets and I could ignore the first giving me 5 buckets, right?<br />
If I asked for 4 buckets then the fifth bucket would only have single max values in it , ie no range. For the most part this bucket will just have the value 1, unless the exact maximum elapsed time happened more than once. I’d prefer the 5th bucket to actually show a range rather than a single value.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
