<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OS与Oracle &#187; CPU used by this session</title>
	<atom:link href="http://www.os2ora.com/tag/cpu-used-by-this-session/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.os2ora.com</link>
	<description>专注于现实世界Oracle数据库的高性能，高可扩展性与新一代数据库Exadata架构</description>
	<lastBuildDate>Fri, 16 Jul 2010 02:55:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>如何分析AWR (5)</title>
		<link>http://www.os2ora.com/how-to-analyze-awr-report-5/</link>
		<comments>http://www.os2ora.com/how-to-analyze-awr-report-5/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 17:21:24 +0000</pubDate>
		<dc:creator>Kaya</dc:creator>
				<category><![CDATA[Oracle管理与维护]]></category>
		<category><![CDATA[数据库性能调优]]></category>
		<category><![CDATA[AWR]]></category>
		<category><![CDATA[AWR分析]]></category>
		<category><![CDATA[CPU used by this session]]></category>
		<category><![CDATA[DB CPU]]></category>
		<category><![CDATA[DB Time]]></category>

		<guid isPermaLink="false">http://www.os2ora.com/how-to-analyze-awr-report-5/</guid>
		<description><![CDATA[有一次跟一个QQ上的朋友一起探讨了另一个对系统CPU进行度量的指标: CPU used by this session。
他刚好有一份AWR报告，在这份报告里，出现了严重的CPU used by this session和DB CPU不一致的现象......]]></description>
			<content:encoded><![CDATA[<p>Kaya 发表于 <a href="http://www.os2ora.com/">os2ora.com</a></p>
<p>有一次跟一个QQ上的朋友一起探讨了另一个对系统CPU进行度量的指标: CPU used by this session。</p>
<p>他刚好有一份AWR报告，在这份报告里，出现了严重的CPU used by this session和DB CPU不一致的现象。</p>
<p>下面是这份报告的一些片断</p>
<p><a href="http://www.os2ora.com/wp-content/uploads/2009/12/image.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="119" alt="image" src="http://www.os2ora.com/wp-content/uploads/2009/12/image_thumb.png" width="509" border="0" /></a> </p>
<p><a href="http://www.os2ora.com/wp-content/uploads/2009/12/image1.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="318" alt="image" src="http://www.os2ora.com/wp-content/uploads/2009/12/image_thumb1.png" width="359" border="0" /></a> </p>
<p><a href="http://www.os2ora.com/wp-content/uploads/2009/12/image2.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="395" alt="image" src="http://www.os2ora.com/wp-content/uploads/2009/12/image_thumb2.png" width="245" border="0" /></a> </p>
<p><a href="http://www.os2ora.com/wp-content/uploads/2009/12/image3.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="56" alt="image" src="http://www.os2ora.com/wp-content/uploads/2009/12/image_thumb3.png" width="524" border="0" /></a> </p>
<p>再做进一步的归纳：</p>
<p>OS Busy% = 1821080/(1821080+5384293) = 25%</p>
<p>Inst CPU% (using DB CPU) = 8934.22*100/(1821080+5384293)=12%</p>
<p>Inst CPU% (using CPU used by this session) = 418035/(1821080+5384293) = 6%</p>
<p>用CPU used by this session计算出的CPU利用率竟然只是用DB CPU计算出来的利用通率的一半！</p>
<p>我的第一个反应是在Jonathan lewis网站看到的一篇相关文章，里面提到了<a href="http://jonathanlewis.wordpress.com/2009/05/26/cpu-used/">DB CPU和CPU used by this session计算时的不同之处:</a></p>
<p><span class="Apple-style-span" style="word-spacing: 0px; font: medium &#39;Times New Roman&#39;; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 13px; line-height: 21px; font-family: verdana, tahoma, arial, sans-serif">“</span></span><span class="Apple-style-span" style="word-spacing: 0px; font: medium &#39;Times New Roman&#39;; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 13px; line-height: 21px; font-family: verdana, tahoma, arial, sans-serif">prior to 10g Oracle usually updated time figures at the end of each database call; but from 10g there are some views where time is updated more regularly.</span></span></p>
<p><span class="Apple-style-span" style="word-spacing: 0px; font: medium &#39;Times New Roman&#39;; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 13px; line-height: 21px; font-family: verdana, tahoma, arial, sans-serif"><span class="Apple-style-span" style="word-spacing: 0px; font: medium &#39;Times New Roman&#39;; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 13px; line-height: 21px; font-family: verdana, tahoma, arial, sans-serif">The<span class="Apple-converted-space">&#160;</span><em>“DB CPU”</em><span class="Apple-converted-space">&#160;</span>from<span class="Apple-converted-space">&#160;</span><em><strong>v$sess_time_model</strong></em><span class="Apple-converted-space">&#160;</span>increases every six seconds, while the<span class="Apple-converted-space">&#160;</span><em>“CPU used by this session”</em><span class="Apple-converted-space">&#160;</span>from<span class="Apple-converted-space">&#160;</span><em><strong>v$sesstat </strong></em>changes only at the end of the test.”</span></span></span></span></p>
<p>如何验证这一点呢？</p>
<p>在浏览这份报告的TOP SQL时，我们发现了下面的现象：</p>
<p><a href="http://www.os2ora.com/wp-content/uploads/2009/12/image4.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="91" alt="image" src="http://www.os2ora.com/wp-content/uploads/2009/12/image_thumb4.png" width="563" border="0" /></a> </p>
<p>这是从SQL ordered by Elapsed Time截取出来的Top 3 SQL。TOP 1的SQL用了DB Time的30.10%，用了2517s 的CPU Time。但请注意它的Executions的值却为0。也就是说，这里的CPU Time是还没有被计算入CPU used by this session这个指标里面的。</p>
<p>我们再把2517s加回来，看出误差缩小多少:(251700+418035)/(1821080+5384293) = 9%</p>
<p>这时和用DB CPU计算出来的12%还是有1/4的差距。</p>
<p>从这个例子可以看出，用DB CPU度量还是比用CPU used by this session来得准确的。特别在有大查询在跑的过程中抓的AWR，这个误差很有可能会被放大。</p>
<p>一个有趣的实际例子。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.os2ora.com/how-to-analyze-awr-report-5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
