<?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>dbaStreet</title>
	<atom:link href="http://dbastreet.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://dbastreet.com/blog</link>
	<description>Oracle, Linux, Open Source and Stuff in General...Experiment, Fail, Learn, Repeat...</description>
	<lastBuildDate>Wed, 16 May 2012 11:23:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sql to extract awr data for analysis</title>
		<link>http://dbastreet.com/blog/?p=849</link>
		<comments>http://dbastreet.com/blog/?p=849#comments</comments>
		<pubDate>Tue, 15 May 2012 20:00:05 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[awr]]></category>
		<category><![CDATA[awr mining]]></category>
		<category><![CDATA[awr trend analysis]]></category>
		<category><![CDATA[awr trending]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql awr analysis]]></category>
		<category><![CDATA[sql awr data]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=849</guid>
		<description><![CDATA[Awr captures a wealth of database performance statistics and metrics. Enterprise manager is usually the preferred tool to interpret and analyze this data. However lot of times i resort to using sql statements to graph and look for trends in the awr data. Below are some of the sql&#8217;s that i use (Tested only in [...]]]></description>
			<content:encoded><![CDATA[<p>Awr captures a wealth of database performance statistics and metrics. Enterprise manager is usually the preferred tool to interpret and analyze this data. However lot of times i resort to using sql statements to graph and look for trends in the awr data. Below are some of the sql&#8217;s that i use (Tested only in 11gr2) to extract this information. Please keep in mind that you need the &#8220;Database tuning pack&#8221; license to access the dba_hist views.</p>
<p>The full script can be downloaded <a href="http://dbastreet.com/sql/awrsql.sql">here</a>.</p>
<h3>Awr Snapshot info by DbId, by Day</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p849code9'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8499"><td class="code" id="p849code9"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">select</span> d<span style="color: #66cc66;">.</span>dbid<span style="color: #66cc66;">,</span>d<span style="color: #66cc66;">.</span>db_name<span style="color: #66cc66;">,</span>to_char<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>begin_interval_time<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-RR'</span><span style="color: #66cc66;">&#41;</span> begintime<span style="color: #66cc66;">,</span>min<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">&#41;</span> minsnap<span style="color: #66cc66;">,</span>max<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">&#41;</span>  maxsnap
              <span style="color: #993333; font-weight: bold;">from</span> dba_hist_snapshot s<span style="color: #66cc66;">,</span>dba_hist_database_instance d <span style="color: #993333; font-weight: bold;">where</span> s<span style="color: #66cc66;">.</span>instance_number <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>
              <span style="color: #993333; font-weight: bold;">and</span> s<span style="color: #66cc66;">.</span>instance_number <span style="color: #66cc66;">=</span> d<span style="color: #66cc66;">.</span>instance_number <span style="color: #993333; font-weight: bold;">and</span> s<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> d<span style="color: #66cc66;">.</span>dbid
              <span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> d<span style="color: #66cc66;">.</span>dbid<span style="color: #66cc66;">,</span>d<span style="color: #66cc66;">.</span>db_name<span style="color: #66cc66;">,</span>to_char<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>begin_interval_time<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-RR'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> <span style="color: #cc66cc;">1</span>
<span style="color: #66cc66;">/</span>
&nbsp;
	       DBID DB_NA BEGINTIME		 MINSNAP   MAXSNAP
<span style="color: #808080; font-style: italic;">------------------- ----- -------------------- --------- ---------</span>
	  <span style="color: #cc66cc;">220594996</span> QAD   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span>		    <span style="color: #cc66cc;">5205</span>      <span style="color: #cc66cc;">5217</span>
	  <span style="color: #cc66cc;">220594996</span> QAD   <span style="color: #cc66cc;">17</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span>		    <span style="color: #cc66cc;">5218</span>      <span style="color: #cc66cc;">5220</span>
	 <span style="color: #cc66cc;">2085202933</span> RK01  <span style="color: #cc66cc;">15</span><span style="color: #66cc66;">-</span>MAY<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">12</span>		       <span style="color: #cc66cc;">3</span>	 <span style="color: #cc66cc;">4</span></pre></td></tr></table></div>

<h3>Database version and platform</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p849code10'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84910"><td class="code" id="p849code10"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">select</span> <span style="color: #993333; font-weight: bold;">distinct</span> version<span style="color: #66cc66;">,</span>platform_name <span style="color: #993333; font-weight: bold;">from</span> dba_hist_database_instance <span style="color: #993333; font-weight: bold;">where</span> dbid<span style="color: #66cc66;">=</span>&amp;amp;dbid
<span style="color: #66cc66;">/</span>
&nbsp;
VERSION           PLATFORM_NAME
<span style="color: #808080; font-style: italic;">----------------- ---------------------------</span>
11<span style="color: #66cc66;">.</span>2<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>2<span style="color: #66cc66;">.</span>0        Linux x86 <span style="color: #cc66cc;">64</span><span style="color: #66cc66;">-</span>bit</pre></td></tr></table></div>

<h3>Cpu&#8217;s/Sockets/Cores/Load Average</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p849code11'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84911"><td class="code" id="p849code11"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> <span style="color: #66cc66;">&#40;</span>
                  <span style="color: #993333; font-weight: bold;">select</span>  stat_name<span style="color: #66cc66;">,</span>value
                  <span style="color: #993333; font-weight: bold;">from</span>  dba_hist_osstat
                  <span style="color: #993333; font-weight: bold;">where</span> dbid <span style="color: #66cc66;">=</span> &amp;amp;dbid
                  <span style="color: #993333; font-weight: bold;">and</span> instance_number <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>
                  <span style="color: #993333; font-weight: bold;">and</span> snap_id <span style="color: #66cc66;">=</span> &amp;amp;esnap
                  <span style="color: #66cc66;">&#41;</span>
                  pivot <span style="color: #66cc66;">&#40;</span>sum<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">for</span> stat_name <span style="color: #993333; font-weight: bold;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'NUM_CPUS'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'NUM_CPU_SOCKETS'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'NUM_CPU_CORES'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'PHYSICAL_MEMORY_BYTES'</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'LOAD'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">/</span>
&nbsp;
<span style="color: #ff0000;">'NUM_CPUS'</span> <span style="color: #ff0000;">'NUM_CPU_SOCKETS'</span> <span style="color: #ff0000;">'NUM_CPU_CORES'</span> <span style="color: #ff0000;">'PHYSICAL_MEMORY_BYTES'</span>     <span style="color: #ff0000;">'LOAD'</span>
<span style="color: #808080; font-style: italic;">---------- ----------------- --------------- ----------------------- ----------</span>
        <span style="color: #cc66cc;">24</span>                 <span style="color: #cc66cc;">2</span>              <span style="color: #cc66cc;">12</span>              1<span style="color: #66cc66;">.</span>0122E<span style="color: #66cc66;">+</span>11 <span style="color: #66cc66;">.</span>209960938</pre></td></tr></table></div>

<h3>O/S Cpu Usage</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p849code12'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84912"><td class="code" id="p849code12"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">select</span>
to_char<span style="color: #66cc66;">&#40;</span>begintime<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-YY HH24:MI:SS'</span><span style="color: #66cc66;">&#41;</span> begintime<span style="color: #66cc66;">,</span>
to_char<span style="color: #66cc66;">&#40;</span>endtime<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-YY HH24:MI:SS'</span><span style="color: #66cc66;">&#41;</span> endtime<span style="color: #66cc66;">,</span>
inst<span style="color: #66cc66;">,</span>
snapid<span style="color: #66cc66;">,</span>
round<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">+</span>itdiff<span style="color: #66cc66;">+</span>stdiff<span style="color: #66cc66;">+</span>iowtdiff<span style="color: #66cc66;">+</span>ntdiff<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>  utpct<span style="color: #66cc66;">,</span>
round<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>ntdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">+</span>itdiff<span style="color: #66cc66;">+</span>stdiff<span style="color: #66cc66;">+</span>iowtdiff<span style="color: #66cc66;">+</span>ntdiff<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>  ntpct<span style="color: #66cc66;">,</span>
round<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>stdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">+</span>itdiff<span style="color: #66cc66;">+</span>stdiff<span style="color: #66cc66;">+</span>iowtdiff<span style="color: #66cc66;">+</span>ntdiff<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>  stpct<span style="color: #66cc66;">,</span>
round<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>iowtdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">+</span>itdiff<span style="color: #66cc66;">+</span>stdiff<span style="color: #66cc66;">+</span>iowtdiff<span style="color: #66cc66;">+</span>ntdiff<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>  iowtpct<span style="color: #66cc66;">,</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">-</span>
<span style="color: #66cc66;">&#40;</span>
 round<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">+</span>itdiff<span style="color: #66cc66;">+</span>stdiff<span style="color: #66cc66;">+</span>iowtdiff<span style="color: #66cc66;">+</span>ntdiff<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">+</span>
 round<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>ntdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">+</span>itdiff<span style="color: #66cc66;">+</span>stdiff<span style="color: #66cc66;">+</span>iowtdiff<span style="color: #66cc66;">+</span>ntdiff<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">+</span>
 round<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>stdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">+</span>itdiff<span style="color: #66cc66;">+</span>stdiff<span style="color: #66cc66;">+</span>iowtdiff<span style="color: #66cc66;">+</span>ntdiff<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">+</span>
 round<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>iowtdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span>utdiff<span style="color: #66cc66;">+</span>itdiff<span style="color: #66cc66;">+</span>stdiff<span style="color: #66cc66;">+</span>iowtdiff<span style="color: #66cc66;">+</span>ntdiff<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> itpct
<span style="color: #993333; font-weight: bold;">from</span>
<span style="color: #66cc66;">&#40;</span>
<span style="color: #993333; font-weight: bold;">select</span> begintime<span style="color: #66cc66;">,</span>endtime<span style="color: #66cc66;">,</span><span style="color: #66cc66;">&#40;</span>extract<span style="color: #66cc66;">&#40;</span>Minute <span style="color: #993333; font-weight: bold;">from</span> endtime<span style="color: #66cc66;">-</span>begintime<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">60</span><span style="color: #66cc66;">+</span>extract<span style="color: #66cc66;">&#40;</span>Second <span style="color: #993333; font-weight: bold;">from</span> endtime<span style="color: #66cc66;">-</span>begintime<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> secs<span style="color: #66cc66;">,</span>
snapid<span style="color: #66cc66;">,</span>inst<span style="color: #66cc66;">,</span>
ut<span style="color: #66cc66;">-</span><span style="color: #66cc66;">&#40;</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>ut<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> utdiff<span style="color: #66cc66;">,</span>
bt<span style="color: #66cc66;">-</span><span style="color: #66cc66;">&#40;</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>bt<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> btdiff<span style="color: #66cc66;">,</span>
it<span style="color: #66cc66;">-</span><span style="color: #66cc66;">&#40;</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>it<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> itdiff<span style="color: #66cc66;">,</span>
st<span style="color: #66cc66;">-</span><span style="color: #66cc66;">&#40;</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>st<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> stdiff<span style="color: #66cc66;">,</span>
iowt<span style="color: #66cc66;">-</span><span style="color: #66cc66;">&#40;</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>iowt<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> iowtdiff<span style="color: #66cc66;">,</span>
nt<span style="color: #66cc66;">-</span><span style="color: #66cc66;">&#40;</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>nt<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> ntdiff<span style="color: #66cc66;">,</span>
vin<span style="color: #66cc66;">-</span><span style="color: #66cc66;">&#40;</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>vin<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> vindiff<span style="color: #66cc66;">,</span>
vout<span style="color: #66cc66;">-</span><span style="color: #66cc66;">&#40;</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>vout<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> voutdiff
<span style="color: #993333; font-weight: bold;">from</span>
<span style="color: #66cc66;">&#40;</span>
<span style="color: #993333; font-weight: bold;">select</span> sn<span style="color: #66cc66;">.</span>begin_interval_time begintime<span style="color: #66cc66;">,</span>
     sn<span style="color: #66cc66;">.</span>end_interval_time EndTime<span style="color: #66cc66;">,</span>oss<span style="color: #66cc66;">.</span>snap_id SnapId<span style="color: #66cc66;">,</span>oss<span style="color: #66cc66;">.</span>instance_number Inst<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>oss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'USER_TIME'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> ut<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>oss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'BUSY_TIME'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> bt<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>oss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'IDLE_TIME'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> it<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>oss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'SYS_TIME'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> st<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>oss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'IOWAIT_TIME'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> iowt<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>oss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'NICE_TIME'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> nt<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>oss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'VM_IN_BYTES'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> vin<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>oss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'VM_OUT_BYTES'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> vout
<span style="color: #993333; font-weight: bold;">from</span> dba_hist_osstat oss<span style="color: #66cc66;">,</span>dba_hist_snapshot sn
<span style="color: #993333; font-weight: bold;">where</span> oss<span style="color: #66cc66;">.</span>dbid<span style="color: #66cc66;">=</span>&amp;amp;dbid
<span style="color: #993333; font-weight: bold;">and</span>   oss<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>dbid
<span style="color: #993333; font-weight: bold;">and</span>   oss<span style="color: #66cc66;">.</span>instance_number <span style="color: #66cc66;">=</span>  sn<span style="color: #66cc66;">.</span>instance_number
<span style="color: #993333; font-weight: bold;">and</span>   oss<span style="color: #66cc66;">.</span>snap_id <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>snap_id
<span style="color: #993333; font-weight: bold;">and</span>   oss<span style="color: #66cc66;">.</span>snap_id <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
<span style="color: #993333; font-weight: bold;">and</span>   oss<span style="color: #66cc66;">.</span>stat_name <span style="color: #993333; font-weight: bold;">in</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">'USER_TIME'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'BUSY_TIME'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'IDLE_TIME'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'SYS_TIME'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'IOWAIT_TIME'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'NICE_TIME'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'VM_IN_BYTES'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'VM_OUT_BYTES'</span>
<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> sn<span style="color: #66cc66;">.</span>begin_interval_time<span style="color: #66cc66;">,</span>sn<span style="color: #66cc66;">.</span>end_interval_time<span style="color: #66cc66;">,</span>oss<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">,</span>oss<span style="color: #66cc66;">.</span>instance_number
<span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> oss<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>oss<span style="color: #66cc66;">.</span>snap_id
<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">where</span> snapid <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
<span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid
<span style="color: #66cc66;">/</span>
&nbsp;
BEGINTIME            ENDTIME               <span style="color: #993333; font-weight: bold;">in</span>     SNAPID  UTPCT  NTPCT  STPCT IOWTPCT  ITPCT
<span style="color: #808080; font-style: italic;">-------------------- -------------------- --- ---------- ------ ------ ------ ------- ------</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1.00</span>    <span style="color: #66cc66;">.</span>00    <span style="color: #66cc66;">.</span>00     <span style="color: #66cc66;">.</span>00  <span style="color: #cc66cc;">99.00</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">40</span>:<span style="color: #cc66cc;">12</span>     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5210</span>   <span style="color: #cc66cc;">4.00</span>    <span style="color: #66cc66;">.</span>00   <span style="color: #cc66cc;">1.00</span>     <span style="color: #66cc66;">.</span>00  <span style="color: #cc66cc;">95.00</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">40</span>:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">22</span>:00:03     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5211</span>  <span style="color: #cc66cc;">31.00</span>    <span style="color: #66cc66;">.</span>00   <span style="color: #cc66cc;">2.00</span>     <span style="color: #66cc66;">.</span>00  <span style="color: #cc66cc;">67.00</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">22</span>:00:03   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">22</span>:<span style="color: #cc66cc;">20</span>:05     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5212</span>  <span style="color: #cc66cc;">58.00</span>    <span style="color: #66cc66;">.</span>00   <span style="color: #cc66cc;">2.00</span>     <span style="color: #66cc66;">.</span>00  <span style="color: #cc66cc;">40.00</span></pre></td></tr></table></div>

<h3>Elapsed Time/DB Time/Concurrent Active Users</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p849code13'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84913"><td class="code" id="p849code13"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">select</span>
to_char<span style="color: #66cc66;">&#40;</span>begintime<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-YY HH24:MI:SS'</span><span style="color: #66cc66;">&#41;</span> begintime<span style="color: #66cc66;">,</span>
to_char<span style="color: #66cc66;">&#40;</span>endtime<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-YY HH24:MI:SS'</span><span style="color: #66cc66;">&#41;</span> endtime<span style="color: #66cc66;">,</span>
inst<span style="color: #66cc66;">,</span>
snapid<span style="color: #66cc66;">,</span>
round<span style="color: #66cc66;">&#40;</span>dbtdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1000000</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">60</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> dbt<span style="color: #66cc66;">,</span>
round<span style="color: #66cc66;">&#40;</span>secs<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">60</span><span style="color: #66cc66;">&#41;</span> mins<span style="color: #66cc66;">,</span>
round<span style="color: #66cc66;">&#40;</span>dbtdiff<span style="color: #66cc66;">/</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1000000</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">60</span><span style="color: #66cc66;">*</span>round<span style="color: #66cc66;">&#40;</span>secs<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">60</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> concactive
<span style="color: #993333; font-weight: bold;">from</span>
<span style="color: #66cc66;">&#40;</span>
<span style="color: #993333; font-weight: bold;">select</span> begintime<span style="color: #66cc66;">,</span>endtime<span style="color: #66cc66;">,</span><span style="color: #66cc66;">&#40;</span>extract<span style="color: #66cc66;">&#40;</span>Minute <span style="color: #993333; font-weight: bold;">from</span> endtime<span style="color: #66cc66;">-</span>begintime<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">60</span><span style="color: #66cc66;">+</span>extract<span style="color: #66cc66;">&#40;</span>Second <span style="color: #993333; font-weight: bold;">from</span> endtime<span style="color: #66cc66;">-</span>begintime<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> secs<span style="color: #66cc66;">,</span>
snapid<span style="color: #66cc66;">,</span>inst<span style="color: #66cc66;">,</span>
dbt<span style="color: #66cc66;">-</span><span style="color: #66cc66;">&#40;</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>dbt<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> dbtdiff
<span style="color: #993333; font-weight: bold;">from</span>
<span style="color: #66cc66;">&#40;</span>
<span style="color: #993333; font-weight: bold;">select</span> sn<span style="color: #66cc66;">.</span>begin_interval_time begintime<span style="color: #66cc66;">,</span>
     sn<span style="color: #66cc66;">.</span>end_interval_time EndTime<span style="color: #66cc66;">,</span>tm<span style="color: #66cc66;">.</span>snap_id SnapId<span style="color: #66cc66;">,</span>tm<span style="color: #66cc66;">.</span>instance_number Inst<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>tm<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DB time'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> dbt
<span style="color: #993333; font-weight: bold;">from</span> dba_hist_sys_time_model tm<span style="color: #66cc66;">,</span>dba_hist_snapshot sn
<span style="color: #993333; font-weight: bold;">where</span> tm<span style="color: #66cc66;">.</span>dbid<span style="color: #66cc66;">=</span>&amp;amp;dbid
<span style="color: #993333; font-weight: bold;">and</span>   tm<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>dbid
<span style="color: #993333; font-weight: bold;">and</span>   tm<span style="color: #66cc66;">.</span>instance_number <span style="color: #66cc66;">=</span>  sn<span style="color: #66cc66;">.</span>instance_number
<span style="color: #993333; font-weight: bold;">and</span>   tm<span style="color: #66cc66;">.</span>snap_id <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>snap_id
<span style="color: #993333; font-weight: bold;">and</span>   tm<span style="color: #66cc66;">.</span>snap_id <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
<span style="color: #993333; font-weight: bold;">and</span>   tm<span style="color: #66cc66;">.</span>stat_name <span style="color: #993333; font-weight: bold;">in</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">'DB time'</span>
<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> sn<span style="color: #66cc66;">.</span>begin_interval_time<span style="color: #66cc66;">,</span>sn<span style="color: #66cc66;">.</span>end_interval_time<span style="color: #66cc66;">,</span>tm<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">,</span>tm<span style="color: #66cc66;">.</span>instance_number
<span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> tm<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>tm<span style="color: #66cc66;">.</span>snap_id
<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">where</span> snapid <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
<span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid
<span style="color: #66cc66;">/</span>
&nbsp;
BEGINTIME            ENDTIME               <span style="color: #993333; font-weight: bold;">in</span>     SNAPID       DBT    MINS CONCACTIVE
<span style="color: #808080; font-style: italic;">-------------------- -------------------- --- ---------- --------- ------- ----------</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5209</span>         <span style="color: #cc66cc;">1</span>      <span style="color: #cc66cc;">20</span>          <span style="color: #cc66cc;">0</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">40</span>:<span style="color: #cc66cc;">12</span>     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5210</span>       <span style="color: #cc66cc;">319</span>      <span style="color: #cc66cc;">20</span>         <span style="color: #cc66cc;">16</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">40</span>:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">22</span>:00:03     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5211</span>       <span style="color: #cc66cc;">657</span>      <span style="color: #cc66cc;">20</span>         <span style="color: #cc66cc;">33</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">22</span>:00:03   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">22</span>:<span style="color: #cc66cc;">20</span>:05     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5212</span>       <span style="color: #cc66cc;">972</span>      <span style="color: #cc66cc;">20</span>         <span style="color: #cc66cc;">49</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">22</span>:<span style="color: #cc66cc;">20</span>:05   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">22</span>:<span style="color: #cc66cc;">40</span>:06     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5213</span>       <span style="color: #cc66cc;">457</span>      <span style="color: #cc66cc;">20</span>         <span style="color: #cc66cc;">23</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">22</span>:<span style="color: #cc66cc;">40</span>:06   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">23</span>:00:08     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5214</span>       <span style="color: #cc66cc;">736</span>      <span style="color: #cc66cc;">20</span>         <span style="color: #cc66cc;">37</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">23</span>:00:08   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">23</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">25</span>     <span style="color: #cc66cc;">1</span>       <span style="color: #cc66cc;">5215</span>         <span style="color: #cc66cc;">3</span>      <span style="color: #cc66cc;">20</span>          <span style="color: #cc66cc;">0</span></pre></td></tr></table></div>

<h3>Top 5 Foreground Waits</h3>
<p>The percentages i get here, do not seem to match up exactly, with the percentages you get, when you run awrrpt.sql, to generate the corresponding awr report. However it always seems to be within + or &#8211; 3% of the awrrpt.sql value. I think that the variation is because of the way that the awrrpt.sql might be rounding values, and probably how it accouts for Idle events.</p>
<p>&nbsp;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p849code14'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84914"><td class="code" id="p849code14"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">with</span> se <span style="color: #993333; font-weight: bold;">as</span> <span style="color: #66cc66;">&#40;</span>
     <span style="color: #993333; font-weight: bold;">select</span> sn<span style="color: #66cc66;">.</span>begin_interval_time begintime<span style="color: #66cc66;">,</span>
        sn<span style="color: #66cc66;">.</span>end_interval_time EndTime<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>snap_id SnapId<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>instance_number Inst<span style="color: #66cc66;">,</span>
        se<span style="color: #66cc66;">.</span>event_name stat<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>time_waited_micro_fg value<span style="color: #66cc66;">,</span>
        nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>se<span style="color: #66cc66;">.</span>time_waited_micro_fg<span style="color: #66cc66;">&#41;</span> over<span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> se<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>event_name
        <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> se<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>event_name<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> prevval<span style="color: #66cc66;">,</span>
        se<span style="color: #66cc66;">.</span>time_waited_micro_fg<span style="color: #66cc66;">-</span>
        nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>se<span style="color: #66cc66;">.</span>time_waited_micro_fg<span style="color: #66cc66;">&#41;</span> over<span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> se<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>event_name
        <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> se<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>event_name<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> valuediff
     <span style="color: #993333; font-weight: bold;">from</span> dba_hist_system_event se<span style="color: #66cc66;">,</span>dba_hist_snapshot sn
     <span style="color: #993333; font-weight: bold;">where</span> se<span style="color: #66cc66;">.</span>dbid<span style="color: #66cc66;">=</span>&amp;amp;dbid
     <span style="color: #993333; font-weight: bold;">and</span>   se<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>dbid
     <span style="color: #993333; font-weight: bold;">and</span>   se<span style="color: #66cc66;">.</span>instance_number <span style="color: #66cc66;">=</span>  sn<span style="color: #66cc66;">.</span>instance_number
     <span style="color: #993333; font-weight: bold;">and</span>   se<span style="color: #66cc66;">.</span>snap_id <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>snap_id
     <span style="color: #993333; font-weight: bold;">and</span>   se<span style="color: #66cc66;">.</span>snap_id <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
     <span style="color: #993333; font-weight: bold;">and</span>   se<span style="color: #66cc66;">.</span>wait_class !<span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'Idle'</span>
     <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> se<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>se<span style="color: #66cc66;">.</span>event_name
     <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">,</span>
     sdbcpu <span style="color: #993333; font-weight: bold;">as</span> <span style="color: #66cc66;">&#40;</span>
         <span style="color: #993333; font-weight: bold;">select</span> sn<span style="color: #66cc66;">.</span>begin_interval_time begintime<span style="color: #66cc66;">,</span>sn<span style="color: #66cc66;">.</span>end_interval_time EndTime<span style="color: #66cc66;">,</span>
         stm<span style="color: #66cc66;">.</span>snap_id snapid<span style="color: #66cc66;">,</span>stm<span style="color: #66cc66;">.</span>instance_number inst<span style="color: #66cc66;">,</span>stm<span style="color: #66cc66;">.</span>stat_name stat
         <span style="color: #66cc66;">,</span>stm<span style="color: #66cc66;">.</span>value value
         <span style="color: #66cc66;">,</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>stm<span style="color: #66cc66;">.</span>value<span style="color: #66cc66;">&#41;</span> over<span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> stm<span style="color: #66cc66;">.</span>instance_number <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> stm<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>stm<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> prevval
         <span style="color: #66cc66;">,</span>stm<span style="color: #66cc66;">.</span>value<span style="color: #66cc66;">-</span>
         nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>stm<span style="color: #66cc66;">.</span>value<span style="color: #66cc66;">&#41;</span> over<span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> stm<span style="color: #66cc66;">.</span>instance_number <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> stm<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>stm<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> valuediff
         <span style="color: #993333; font-weight: bold;">from</span> dba_hist_sys_time_model stm<span style="color: #66cc66;">,</span>dba_hist_snapshot sn
         <span style="color: #993333; font-weight: bold;">where</span>
         stm<span style="color: #66cc66;">.</span>stat_name <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'DB CPU'</span><span style="color: #66cc66;">&#41;</span>
         <span style="color: #993333; font-weight: bold;">and</span> stm<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> &amp;amp;dbid
         <span style="color: #993333; font-weight: bold;">and</span> stm<span style="color: #66cc66;">.</span>snap_id <span style="color: #993333; font-weight: bold;">between</span>  &amp;amp;bsnap<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
         <span style="color: #993333; font-weight: bold;">and</span> stm<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>dbid
         <span style="color: #993333; font-weight: bold;">and</span> stm<span style="color: #66cc66;">.</span>instance_number <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>instance_number
         <span style="color: #993333; font-weight: bold;">and</span> stm<span style="color: #66cc66;">.</span>snap_id <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>snap_id
         <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> stm<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">,</span>stm<span style="color: #66cc66;">.</span>instance_number
     <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">,</span>
     sunion <span style="color: #993333; font-weight: bold;">as</span> <span style="color: #66cc66;">&#40;</span>
         <span style="color: #993333; font-weight: bold;">select</span> begintime<span style="color: #66cc66;">,</span>endtime<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">,</span>inst<span style="color: #66cc66;">,</span>stat<span style="color: #66cc66;">,</span>valuediff <span style="color: #993333; font-weight: bold;">from</span> se
         <span style="color: #993333; font-weight: bold;">union</span> <span style="color: #993333; font-weight: bold;">all</span>
         <span style="color: #993333; font-weight: bold;">select</span> begintime<span style="color: #66cc66;">,</span>endtime<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">,</span>inst<span style="color: #66cc66;">,</span>stat<span style="color: #66cc66;">,</span>valuediff <span style="color: #993333; font-weight: bold;">from</span> sdbcpu
         <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">4</span>
     <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
     spct <span style="color: #993333; font-weight: bold;">as</span> <span style="color: #66cc66;">&#40;</span>
     <span style="color: #993333; font-weight: bold;">select</span> begintime<span style="color: #66cc66;">,</span>endtime<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">,</span>inst<span style="color: #66cc66;">,</span>stat<span style="color: #66cc66;">,</span>valuediff<span style="color: #66cc66;">,</span>
     round<span style="color: #66cc66;">&#40;</span>ratio_to_report<span style="color: #66cc66;">&#40;</span>valuediff<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> snapid<span style="color: #66cc66;">,</span>inst<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">as</span> pct
     <span style="color: #993333; font-weight: bold;">from</span> sunion
     <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">asc</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">7</span>  <span style="color: #993333; font-weight: bold;">desc</span>
     <span style="color: #66cc66;">&#41;</span>
     <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> <span style="color: #66cc66;">&#40;</span>
     <span style="color: #993333; font-weight: bold;">select</span> to_char<span style="color: #66cc66;">&#40;</span>begintime<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-RR HH24:MI:SS'</span><span style="color: #66cc66;">&#41;</span> begintime
     <span style="color: #66cc66;">,</span>to_char<span style="color: #66cc66;">&#40;</span>endtime<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-RR HH24:MI:SS'</span><span style="color: #66cc66;">&#41;</span> endtime<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">,</span>inst<span style="color: #66cc66;">,</span>stat<span style="color: #66cc66;">,</span>valuediff<span style="color: #66cc66;">,</span>round<span style="color: #66cc66;">&#40;</span>pct<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> pct<span style="color: #66cc66;">,</span>
     row_number<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> snapid<span style="color: #66cc66;">,</span>inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> snapid<span style="color: #66cc66;">,</span>inst <span style="color: #993333; font-weight: bold;">asc</span><span style="color: #66cc66;">,</span>pct <span style="color: #993333; font-weight: bold;">desc</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">as</span> rnum
     <span style="color: #993333; font-weight: bold;">from</span> spct
     <span style="color: #66cc66;">&#41;</span>
     <span style="color: #993333; font-weight: bold;">where</span> rnum &amp;lt; <span style="color: #cc66cc;">6</span> <span style="color: #993333; font-weight: bold;">and</span> snapid <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
<span style="color: #66cc66;">/</span>
&nbsp;
BEGINTIME            ENDTIME                  SNAPID  <span style="color: #993333; font-weight: bold;">in</span> STAT                               VALUEDIFF    PCT
<span style="color: #808080; font-style: italic;">-------------------- -------------------- ---------- --- ------------------------------ ------------- ------</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> DB CPU                              <span style="color: #cc66cc;">28856557</span>  <span style="color: #cc66cc;">83.24</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> name<span style="color: #66cc66;">-</span>service call wait               <span style="color: #cc66cc;">2073440</span>   <span style="color: #cc66cc;">5.98</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> control file sequential <span style="color: #993333; font-weight: bold;">read</span>          <span style="color: #cc66cc;">843201</span>   <span style="color: #cc66cc;">2.43</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> enq: PS <span style="color: #66cc66;">-</span> contention                  <span style="color: #cc66cc;">634127</span>   <span style="color: #cc66cc;">1.83</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> undo segment extension                <span style="color: #cc66cc;">423219</span>   <span style="color: #cc66cc;">1.22</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">2</span> DB CPU                              <span style="color: #cc66cc;">34408715</span>  <span style="color: #cc66cc;">89.73</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">2</span> enq: PS <span style="color: #66cc66;">-</span> contention                  <span style="color: #cc66cc;">852207</span>   <span style="color: #cc66cc;">2.22</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">2</span> reliable message                      <span style="color: #cc66cc;">351905</span>    <span style="color: #66cc66;">.</span>92
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">2</span> control file sequential <span style="color: #993333; font-weight: bold;">read</span>          <span style="color: #cc66cc;">323355</span>    <span style="color: #66cc66;">.</span>84
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00:<span style="color: #cc66cc;">12</span>   <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:<span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">16</span>         <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">2</span> row cache <span style="color: #993333; font-weight: bold;">lock</span>                        <span style="color: #cc66cc;">286882</span>    <span style="color: #66cc66;">.</span>75</pre></td></tr></table></div>

<h3>Physical and Logical I/O</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p849code15'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84915"><td class="code" id="p849code15"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">select</span> to_char<span style="color: #66cc66;">&#40;</span>begintime<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-RR HH24:MI'</span><span style="color: #66cc66;">&#41;</span> begintime<span style="color: #66cc66;">,</span>to_char<span style="color: #66cc66;">&#40;</span>endtime<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'DD-MON-RR HH24:MI'</span><span style="color: #66cc66;">&#41;</span> endtime
<span style="color: #66cc66;">,</span><span style="color: #66cc66;">&#40;</span>extract<span style="color: #66cc66;">&#40;</span>Minute <span style="color: #993333; font-weight: bold;">from</span> endtime<span style="color: #66cc66;">-</span>begintime<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">60</span><span style="color: #66cc66;">+</span>extract<span style="color: #66cc66;">&#40;</span>Second <span style="color: #993333; font-weight: bold;">from</span> endtime<span style="color: #66cc66;">-</span>begintime<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> secs<span style="color: #66cc66;">,</span>
snapid<span style="color: #66cc66;">,</span>inst<span style="color: #66cc66;">,</span>
prd<span style="color: #66cc66;">-</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>prd<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> prddiff<span style="color: #66cc66;">,</span>
pwrt<span style="color: #66cc66;">-</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>pwrt<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> pwrtdiff<span style="color: #66cc66;">,</span>
iordreq<span style="color: #66cc66;">-</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>iordreq<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> iorddiff<span style="color: #66cc66;">,</span>
iowrtreq<span style="color: #66cc66;">-</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>iowrtreq<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> iowrtdiff<span style="color: #66cc66;">,</span>
prmbr<span style="color: #66cc66;">-</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>prmbr<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> prmbrdiff<span style="color: #66cc66;">,</span>
cgets<span style="color: #66cc66;">-</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>cgets<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> cgetsdiff<span style="color: #66cc66;">,</span>
dbgets<span style="color: #66cc66;">-</span>nvl<span style="color: #66cc66;">&#40;</span>lag<span style="color: #66cc66;">&#40;</span>dbgets<span style="color: #66cc66;">&#41;</span> over <span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> inst <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> inst<span style="color: #66cc66;">,</span>snapid<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> dbgetsdiff
<span style="color: #993333; font-weight: bold;">from</span>
<span style="color: #66cc66;">&#40;</span>
<span style="color: #993333; font-weight: bold;">select</span> sn<span style="color: #66cc66;">.</span>begin_interval_time begintime<span style="color: #66cc66;">,</span>
     sn<span style="color: #66cc66;">.</span>end_interval_time EndTime<span style="color: #66cc66;">,</span>ss<span style="color: #66cc66;">.</span>snap_id SnapId<span style="color: #66cc66;">,</span>ss<span style="color: #66cc66;">.</span>instance_number Inst<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'physical read total bytes'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> prd<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'physical write total bytes'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> pwrt<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'physical read total IO requests'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> iordreq<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'physical write total IO requests'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> iowrtreq<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'physical read total multi block requests'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> prmbr<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'consistent gets'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> cgets<span style="color: #66cc66;">,</span>
     sum<span style="color: #66cc66;">&#40;</span>decode<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>stat_name<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'db block gets'</span><span style="color: #66cc66;">,</span>value<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> dbgets
<span style="color: #993333; font-weight: bold;">from</span> dba_hist_sysstat ss<span style="color: #66cc66;">,</span>dba_hist_snapshot sn
<span style="color: #993333; font-weight: bold;">where</span> ss<span style="color: #66cc66;">.</span>dbid<span style="color: #66cc66;">=</span>&amp;amp;dbid
<span style="color: #993333; font-weight: bold;">and</span>   ss<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>dbid
<span style="color: #993333; font-weight: bold;">and</span>   ss<span style="color: #66cc66;">.</span>instance_number <span style="color: #66cc66;">=</span>  sn<span style="color: #66cc66;">.</span>instance_number
<span style="color: #993333; font-weight: bold;">and</span>   ss<span style="color: #66cc66;">.</span>snap_id <span style="color: #66cc66;">=</span> sn<span style="color: #66cc66;">.</span>snap_id
<span style="color: #993333; font-weight: bold;">and</span>   ss<span style="color: #66cc66;">.</span>snap_id <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
<span style="color: #993333; font-weight: bold;">and</span>   ss<span style="color: #66cc66;">.</span>stat_name <span style="color: #993333; font-weight: bold;">in</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #ff0000;">'physical read total bytes'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'physical write total bytes'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'physical read total IO requests'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'physical write total IO requests'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'physical read total multi block requests'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'consistent gets'</span><span style="color: #66cc66;">,</span>
<span style="color: #ff0000;">'db block gets'</span>
<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> sn<span style="color: #66cc66;">.</span>begin_interval_time<span style="color: #66cc66;">,</span>sn<span style="color: #66cc66;">.</span>end_interval_time<span style="color: #66cc66;">,</span>ss<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">,</span>ss<span style="color: #66cc66;">.</span>instance_number
<span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> ss<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>ss<span style="color: #66cc66;">.</span>snap_id
<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">where</span> snapid <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
<span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">5</span>
<span style="color: #66cc66;">/</span>
&nbsp;
BEGINTIME            ENDTIME                    SECS     SNAPID  <span style="color: #993333; font-weight: bold;">in</span>          PRDDIFF         PWRTDIFF         IORDDIFF        IOWRTDIFF        PRMBRDIFF        CGETSDIFF       DBGETSDIFF
<span style="color: #808080; font-style: italic;">-------------------- -------------------- ---------- ---------- --- ---------------- ---------------- ---------------- ---------------- ---------------- ---------------- ----------------</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">40</span>      <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00        <span style="color: #cc66cc;">1210.766</span>       <span style="color: #cc66cc;">5208</span>   <span style="color: #cc66cc;">1</span>     <span style="color: #cc66cc;">309967486976</span>     <span style="color: #cc66cc;">544388304896</span>         <span style="color: #cc66cc;">17660147</span>         <span style="color: #cc66cc;">36335142</span>          <span style="color: #cc66cc;">1139579</span>       <span style="color: #cc66cc;">4468788730</span>       <span style="color: #cc66cc;">2328671039</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">40</span>      <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00        <span style="color: #cc66cc;">1210.782</span>       <span style="color: #cc66cc;">5208</span>   <span style="color: #cc66cc;">2</span>     <span style="color: #cc66cc;">165472269312</span>     <span style="color: #cc66cc;">510302864896</span>         <span style="color: #cc66cc;">16065810</span>         <span style="color: #cc66cc;">34894618</span>           <span style="color: #cc66cc;">144948</span>       <span style="color: #cc66cc;">4168326257</span>       <span style="color: #cc66cc;">2064355182</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">42</span>      <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00        <span style="color: #cc66cc;">1079.081</span>       <span style="color: #cc66cc;">5208</span>   <span style="color: #cc66cc;">3</span>       <span style="color: #cc66cc;">3122675712</span>        <span style="color: #cc66cc;">153791488</span>            <span style="color: #cc66cc;">56249</span>             <span style="color: #cc66cc;">6006</span>            <span style="color: #cc66cc;">10713</span>          <span style="color: #cc66cc;">1307859</span>            <span style="color: #cc66cc;">60272</span>
<span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">20</span>:<span style="color: #cc66cc;">43</span>      <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">-</span>NOV<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> <span style="color: #cc66cc;">21</span>:00        <span style="color: #cc66cc;">1028.123</span>       <span style="color: #cc66cc;">5208</span>   <span style="color: #cc66cc;">4</span>       <span style="color: #cc66cc;">1318486016</span>         <span style="color: #cc66cc;">59018752</span>            <span style="color: #cc66cc;">26009</span>             <span style="color: #cc66cc;">5436</span>             <span style="color: #cc66cc;">7229</span>          <span style="color: #cc66cc;">1199275</span>            <span style="color: #cc66cc;">56027</span></pre></td></tr></table></div>

<h3>Top 10 sql statements By Elapsed Time</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p849code16'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84916"><td class="code" id="p849code16"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> <span style="color: #66cc66;">&#40;</span>
<span style="color: #993333; font-weight: bold;">select</span> ss<span style="color: #66cc66;">.</span>snap_id snapid<span style="color: #66cc66;">,</span>ss<span style="color: #66cc66;">.</span>instance_number inst<span style="color: #66cc66;">,</span>ss<span style="color: #66cc66;">.</span>sql_id  sqlid
       <span style="color: #66cc66;">,</span>round<span style="color: #66cc66;">&#40;</span>sum<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>elapsed_time_delta<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> elapsed
       <span style="color: #66cc66;">,</span>nvl<span style="color: #66cc66;">&#40;</span>round<span style="color: #66cc66;">&#40;</span>sum<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>executions_delta<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> execs
       <span style="color: #66cc66;">,</span>round<span style="color: #66cc66;">&#40;</span>sum<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>buffer_gets_delta<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> gets
       <span style="color: #66cc66;">,</span>round<span style="color: #66cc66;">&#40;</span>sum<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>rows_processed_delta<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> rowsp
       <span style="color: #66cc66;">,</span>round<span style="color: #66cc66;">&#40;</span>sum<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>disk_reads_delta<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> reads
       <span style="color: #66cc66;">,</span>dense_rank<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> over<span style="color: #66cc66;">&#40;</span>partition <span style="color: #993333; font-weight: bold;">by</span> snap_id<span style="color: #66cc66;">,</span>instance_number <span style="color: #993333; font-weight: bold;">order</span> <span style="color: #993333; font-weight: bold;">by</span> sum<span style="color: #66cc66;">&#40;</span>ss<span style="color: #66cc66;">.</span>elapsed_time_delta<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">desc</span><span style="color: #66cc66;">&#41;</span> sql_rank
<span style="color: #993333; font-weight: bold;">from</span>
dba_hist_sqlstat ss
<span style="color: #993333; font-weight: bold;">where</span>
ss<span style="color: #66cc66;">.</span>dbid <span style="color: #66cc66;">=</span> &amp;amp;dbid  <span style="color: #993333; font-weight: bold;">and</span>
ss<span style="color: #66cc66;">.</span>snap_id <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
<span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> ss<span style="color: #66cc66;">.</span>snap_id<span style="color: #66cc66;">,</span>ss<span style="color: #66cc66;">.</span>instance_number<span style="color: #66cc66;">,</span>ss<span style="color: #66cc66;">.</span>sql_id
<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">where</span> sql_rank &amp;lt; <span style="color: #cc66cc;">11</span> <span style="color: #993333; font-weight: bold;">and</span> snapid <span style="color: #993333; font-weight: bold;">between</span> &amp;amp;bsnap <span style="color: #993333; font-weight: bold;">and</span> &amp;amp;esnap
<span style="color: #66cc66;">/</span>
&nbsp;
   SNAPID  <span style="color: #993333; font-weight: bold;">in</span> SQLID                                ELAPSED      EXECS           GETS          ROWSP          READS   SQL_RANK
<span style="color: #808080; font-style: italic;">---------- --- ------------------------------ ------------- ---------- -------------- -------------- -------------- ----------</span>
      <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> 1zr2ujm5sa5gc                        <span style="color: #cc66cc;">4547685</span>          <span style="color: #cc66cc;">1</span>         <span style="color: #cc66cc;">224434</span>              <span style="color: #cc66cc;">1</span>              <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">1</span>
      <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> 3g2ugdp1af2h8                        <span style="color: #cc66cc;">4478848</span>         <span style="color: #cc66cc;">13</span>         <span style="color: #cc66cc;">221134</span>             <span style="color: #cc66cc;">13</span>              <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">2</span>
      <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> 5k5v1ah25fb2c                        <span style="color: #cc66cc;">3965629</span>         <span style="color: #cc66cc;">39</span>         <span style="color: #cc66cc;">360232</span>             <span style="color: #cc66cc;">39</span>              <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">3</span>
      <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> 0r1zf55mxaujd                        <span style="color: #cc66cc;">2959144</span>          <span style="color: #cc66cc;">1</span>         <span style="color: #cc66cc;">237437</span>              <span style="color: #cc66cc;">1</span>              <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">4</span>
      <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> 8vwv6hx92ymmm                        <span style="color: #cc66cc;">2633353</span>      <span style="color: #cc66cc;">51062</span>         <span style="color: #cc66cc;">360669</span>          <span style="color: #cc66cc;">51062</span>              <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">5</span>
      <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> 2w1s3wu1zw63a                        <span style="color: #cc66cc;">1958993</span>          <span style="color: #cc66cc;">2</span>         <span style="color: #cc66cc;">153110</span>              <span style="color: #cc66cc;">4</span>              <span style="color: #cc66cc;">0</span>          <span style="color: #cc66cc;">6</span>
      <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> f1y8kbhh6v9sv                        <span style="color: #cc66cc;">1709282</span>          <span style="color: #cc66cc;">1</span>                                                       <span style="color: #cc66cc;">7</span>
      <span style="color: #cc66cc;">5209</span>   <span style="color: #cc66cc;">1</span> 6pw8uk8k0dv0q                        <span style="color: #cc66cc;">1699402</span>          <span style="color: #cc66cc;">1</span>                                                       <span style="color: #cc66cc;">8</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=849</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Python 3</title>
		<link>http://dbastreet.com/blog/?p=845</link>
		<comments>http://dbastreet.com/blog/?p=845#comments</comments>
		<pubDate>Wed, 09 May 2012 21:25:17 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[cx_oracle]]></category>
		<category><![CDATA[matplotlib]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python3]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=845</guid>
		<description><![CDATA[I have been writing some python scripts for awr analysis and trending. Since python 2.7 is no longer being enhanced, i have now switched to using python 3. Lot of python applications and frameworks still does not support python 3 (Notably the Django framework). Good news is that cx_oracle works with python 3. The steps [...]]]></description>
			<content:encoded><![CDATA[<p>I have been writing some python scripts for awr analysis and trending. Since python 2.7 is no longer being enhanced, i have now switched to using python 3. Lot of python applications and frameworks still does not support python 3 (Notably the Django framework). Good news is that cx_oracle works with python 3.</p>
<p>The steps to install cx_oracle with python 3 are very similar to the steps that i had outlined in my <a href="http://dbastreet.com/blog/?p=527">previous post on installing cx_oracle with python 2.7</a>.</p>
<p>The difference is that</p>
<p>- You have to first install python3 and python3-dev (On ubuntu, you can just use the ubuntu software center to do this)</p>
<p>- Then download the cx_oracle 5.1.1 source code only tar ball from <a href="http://cx-oracle.sourceforge.net/">http://cx-oracle.sourceforge.net/</a></p>
<p>- login as root, untar the tar file, cd to the cx_Oracle-5.1.1 directory</p>
<p>- Then run /usr/bin/python3 setup.py install</p>
<p>That does it and now oracle connectivity is in place.</p>
<p>I&#8217;ve also been using the <a href="http://matplotlib.sourceforge.net/">matplotlib</a> library along with Python to plot graphs with the awr and oswatcher data files. matplotlib also works with python 3.</p>
<p>- You have to first install libpng, libpng-dev, libfreetype6, libfreetype6-dev (Use the ubuntu software center)</p>
<p>- Download the <a href="http://sourceforge.net/projects/numpy/files/NumPy/">numpy source code tar ball</a>.</p>
<p>- Extract the tar file, login as root, cd to the directory and run /usr/bin/python3 setup.py install</p>
<p>- Installing matplotlib Ref :</p>
<div><strong id="internal-source-marker_0.7951428461819887"><a href="http://stackoverflow.com/questions/8605847/how-to-install-matplotlib-with-python3-2">http://stackoverflow.com/questions/8605847/how-to-install-matplotlib-with-python3-2</a></strong></div>
<p>- Download the <a href="https://github.com/matplotlib/matplotlib/tarball/master">matplotlib source code tar file</a></p>
<p>- Login as root, cd to the directory</p>
<p>- /usr/bin/python3 setup.py build</p>
<p>- /usr/bin/python3 setup.py install</p>
<p>Now you should have matplotlib working with python3</p>
<p>Enjoy your python scripting</p>
<div><strong><br />
</strong></div>
]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=845</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving awr data from 10gR2 to 11gR2 using awrextr.sql and awrload.sql</title>
		<link>http://dbastreet.com/blog/?p=840</link>
		<comments>http://dbastreet.com/blog/?p=840#comments</comments>
		<pubDate>Thu, 26 Apr 2012 14:51:53 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[10gr2]]></category>
		<category><![CDATA[awrextr.sql]]></category>
		<category><![CDATA[awrload.sql 11gr2]]></category>
		<category><![CDATA[move awr data from 10g to 11g]]></category>
		<category><![CDATA[move awr data from 10gr2 to 11gr2]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=840</guid>
		<description><![CDATA[I have been wondering for a while whether we could export awr data from a 10gr2 database (awrextr.sql) and load it into an 11gr2 database (awrload.sql). I got to test this yesterday and it works fine. I was able to do the awrload.sql with No errors. Afterwords i even ran the 11gr2 awrrpti.sql script to [...]]]></description>
			<content:encoded><![CDATA[<p>I have been wondering for a while whether we could export awr data from a 10gr2 database (awrextr.sql) and load it into an 11gr2 database (awrload.sql). I got to test this yesterday and it works fine. I was able to do the awrload.sql with No errors. Afterwords i even ran the 11gr2 awrrpti.sql script to generate awr reports using this data. It produces awr reports, but as one would expect, the portions where the data is not available in 10gR2 (eg: wait event histograms), the report just says &#8220;no data exists for this section of the report&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=840</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VirtualBox command line start, stop and clone</title>
		<link>http://dbastreet.com/blog/?p=837</link>
		<comments>http://dbastreet.com/blog/?p=837#comments</comments>
		<pubDate>Tue, 24 Apr 2012 14:19:19 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[11gr2]]></category>
		<category><![CDATA[clone]]></category>
		<category><![CDATA[clonevm]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[savestate]]></category>
		<category><![CDATA[startvm]]></category>
		<category><![CDATA[VBoxManage]]></category>
		<category><![CDATA[virtualbox]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=837</guid>
		<description><![CDATA[I find it convenient to install the oracle 11gr2 rdbms on Oracle Enterprise Linux 5, running as a virtual host using  VirtualBox  VM (That way i dont have to go through the pains of installing it on Ubuntu Linux, which is unsupported). I use this database on a daily basis for testing different oracle functionality. I use [...]]]></description>
			<content:encoded><![CDATA[<p>I find it convenient to install the oracle 11gr2 rdbms on Oracle Enterprise Linux 5, running as a virtual host using  VirtualBox  VM (That way i dont have to go through the pains of installing it on Ubuntu Linux, which is unsupported). I use this database on a daily basis for testing different oracle functionality.</p>
<p>I use the following virtualbox command line commands to start and stop the virtual machine. It is much faster that booting up the operating system and then starting oracle.</p>
<p>To stop the virtual machine(I have named the VM OEL7) , in its current state (With the oracle rdbms running)</p>
<p><strong>$ VBoxManage  controlvm OEL7 savestate</strong></p>
<p>To start it</p>
<p><strong>$VBoxManage  startvm OEL7</strong></p>
<p>It takes about 10 seconds to start it.</p>
<p>To make a clone of the Virtual Machine to a entirely new location. First shutdown the virtual machine and then</p>
<p><strong>$VBoxManage clonevm OEL7 &#8211;options keepallmacs &#8211;name OEL7E &#8211;basefolder &#8220;/media/ExternalDrive/vimage2&#8243;</strong></p>
<p>The &#8211;basefolder can be specified to be a new location on disk to create the new image.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=837</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ruby 1.9.2 And Rails 3.1.1 with Oracle 11.2.0.3 on Ubuntu 11.10 Oneiric</title>
		<link>http://dbastreet.com/blog/?p=788</link>
		<comments>http://dbastreet.com/blog/?p=788#comments</comments>
		<pubDate>Mon, 21 Nov 2011 00:18:25 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[oracle 11.2.3]]></category>
		<category><![CDATA[oracle 11gr2]]></category>
		<category><![CDATA[rails 3.1]]></category>
		<category><![CDATA[rails 3.1.1]]></category>
		<category><![CDATA[ubuntu 11.10]]></category>
		<category><![CDATA[ubuntu oneiric]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=788</guid>
		<description><![CDATA[Here are the steps to install and configure Ruby on rails with oracle 11.2.0.3 on 32 bit Ubuntu 11.10 Oneiric. First install the pacakges needed by oracle ?View Code BASHsudo apt-get install x11-utils rpm ksh lsb-rpm libaio1 sudo ln -s /usr/include/i386-linux-gnu/sys /usr/include/sys Download the oracle instant client Download the following .zip files from the oracle [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the steps to install and configure Ruby on rails with oracle 11.2.0.3 on 32 bit Ubuntu 11.10 Oneiric.</p>
<h3>First install the pacakges needed by oracle</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code29'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78829"><td class="code" id="p788code29"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> x11-utils rpm ksh lsb-rpm libaio1
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>i386-linux-gnu<span style="color: #000000; font-weight: bold;">/</span>sys <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>sys</pre></td></tr></table></div>

<h3>Download the oracle instant client</h3>
<p>Download the following .zip files from the <a href="http://www.oracle.com/technetwork/topics/linuxsoft-082809.html">oracle instant client download site</a>.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code30'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78830"><td class="code" id="p788code30"><pre class="bash" style="font-family:monospace;">instantclient-basiclite-linux-11.2.0.3.0.zip
instantclient-sqlplus-linux-11.2.0.3.0.zip
instantclient-sdk-linux-11.2.0.3.0.zip</pre></td></tr></table></div>

<h3><span class="Apple-style-span" style="font-size: 15px; font-weight: bold;">Install the oracle InstantClient</span></h3>
<p>Create a directory /u01/11gr2</p>
<p>cd /u01/11gr2</p>
<p>unzip the above 3 .zip files into this directory</p>
<p>You will have a new subdirectory named instantclient_11_2</p>
<p>Create a softlink to libclntsh.so</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code31'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78831"><td class="code" id="p788code31"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>11gr2<span style="color: #000000; font-weight: bold;">/</span>instantclient_11_2
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> libclntsh.so.11.1 libclntsh.so</pre></td></tr></table></div>

<p>&nbsp;</p>
<p><strong>Setup the Oracle environment</strong></p>
<p>Add the following to your .bashrc file (And source the file, . ./.bashrc)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code32'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78832"><td class="code" id="p788code32"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ORACLE_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>u01<span style="color: #000000; font-weight: bold;">/</span>11gr2<span style="color: #000000; font-weight: bold;">/</span>instantclient_11_2
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LD_LIBRARY_PATH</span>=<span style="color: #007800;">$ORACLE_HOME</span><span style="color: #000000; font-weight: bold;">/</span>lib:<span style="color: #007800;">$LD_LIBRARY_PATH</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">TNS_ADMIN</span>=<span style="color: #007800;">$ORACLE_HOME</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Create the tnsnames.ora file in /u01/11gr2/instantclient_11_2</p>
<p>Add service name entry for your oracle database  to the tnsnames.ora</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code33'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78833"><td class="code" id="p788code33"><pre class="bash" style="font-family:monospace;">RK01 =
  <span style="color: #7a0874; font-weight: bold;">&#40;</span>DESCRIPTION =
    <span style="color: #7a0874; font-weight: bold;">&#40;</span>ADDRESS = <span style="color: #7a0874; font-weight: bold;">&#40;</span>PROTOCOL = TCP<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>HOST = burl5vb1<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>PORT = <span style="color: #000000;">1521</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #7a0874; font-weight: bold;">&#40;</span>CONNECT_DATA =
      <span style="color: #7a0874; font-weight: bold;">&#40;</span>SERVER = DEDICATED<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">&#40;</span>SERVICE_NAME = rk01<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<h3>Install Ruby 1.9.2</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code34'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78834"><td class="code" id="p788code34"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> curl
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> git-core
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">git</span> config <span style="color: #660033;">--global</span> user.name <span style="color: #ff0000;">&quot;YourNameHere&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> config <span style="color: #660033;">--global</span> user.emailbash YourEmailHere
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>lt; <span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-s</span> https:<span style="color: #000000; font-weight: bold;">//</span>rvm.beginrescueend.com<span style="color: #000000; font-weight: bold;">/</span>install<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> build-essential <span style="color: #c20cb9; font-weight: bold;">bison</span> openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-<span style="color: #000000;">0</span> libsqlite3-dev sqlite3libxml2-dev libxslt-dev <span style="color: #c20cb9; font-weight: bold;">autoconf</span> libc6-dev ncurses-dev
&nbsp;
rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.9.2
rvm <span style="color: #660033;">--default</span> use 1.9.2</pre></td></tr></table></div>

<h3>Install Rails 3.1.1</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code35'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78835"><td class="code" id="p788code35"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</pre></td></tr></table></div>

<h3>Installing and using the oracle driver.</h3>
<p>You can include the download and install of the oracle-advanced driver and the oci8 driver in the Gemfile for your application.</p>
<p>So that when you do the bundle install, it will install those gems for you.</p>
<p>Example shown below.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code36'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78836"><td class="code" id="p788code36"><pre class="bash" style="font-family:monospace;">rails new testora
<span style="color: #7a0874; font-weight: bold;">cd</span> testora</pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Add the following lines to your Gemfile (In the application base directory)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code37'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78837"><td class="code" id="p788code37"><pre class="bash" style="font-family:monospace;">gem <span style="color: #ff0000;">'activerecord-oracle_enhanced-adapter'</span>, :<span style="color: #c20cb9; font-weight: bold;">git</span> =<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #ff0000;">'git://github.com/rsim/oracle-enhanced.git'</span>
gem <span style="color: #ff0000;">'ruby-oci8'</span>, <span style="color: #ff0000;">'~&amp;gt; 2.0.6'</span></pre></td></tr></table></div>

<p>Save and quit from Gemfile</p>
<p>Run the following command to install all the gems you need for the application</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code38'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78838"><td class="code" id="p788code38"><pre class="bash" style="font-family:monospace;">bundle <span style="color: #c20cb9; font-weight: bold;">install</span></pre></td></tr></table></div>

<p>Remove all the other entroes and add the database connection entry to your database.yml file (Under testora/config).</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code39'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78839"><td class="code" id="p788code39"><pre class="bash" style="font-family:monospace;">development:
  adapter: oracle_enhanced
  database: rk01
  username: scott
  password: tiger</pre></td></tr></table></div>

<h3>Create your application and run it</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p788code40'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p78840"><td class="code" id="p788code40"><pre class="bash" style="font-family:monospace;">rails generate scaffold purchase name:string cost:float
rake db:migrate
rails server</pre></td></tr></table></div>

<p>You can access the application from the following URL.</p>
<p>http://localhost:3000/purchases</p>
<p>&nbsp;</p>
<p>Now you should be able to run your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=788</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to influence the execution plan without modifying the sql from the application</title>
		<link>http://dbastreet.com/blog/?p=758</link>
		<comments>http://dbastreet.com/blog/?p=758#comments</comments>
		<pubDate>Tue, 15 Nov 2011 16:12:03 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dbms_spm]]></category>
		<category><![CDATA[dbms_spm modify execution plan with hint]]></category>
		<category><![CDATA[modify execution plan without a hint]]></category>
		<category><![CDATA[sql plan baseline]]></category>
		<category><![CDATA[sql plan management]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=758</guid>
		<description><![CDATA[It is likely that all of us have encountered the following situation. Your company runs a packaged application, you get some poorly performing sql, root cause happens to be the bad execution plan. You could battle statistics and see if you can get the optimizer to pick a better plan. One of the options, is [...]]]></description>
			<content:encoded><![CDATA[<p>It is likely that all of us have encountered the following situation. Your company runs a packaged application, you get some poorly performing sql, root cause happens to be the bad execution plan. You could battle statistics and see if you can get the optimizer to pick a better plan. One of the options, is to put this sql through the sql tuning advisor and see if it comes up with a sql profile that improves the execution plan, and if it does, to accept the profile.</p>
<p>Some of these performance issues could be critical, and require urgent resolution. In such urgent situations, you might catch yourself thinking, &#8220;I wish i could hint this query to get it to pick a better execution plan&#8221;. However, this being a packaged application, your hands are tied.</p>
<p>This year at oracle openworld 2011, Maria Colgan and Mohamed Zait, presented a session  &#8221;Oracle Database Optimizer : Tips for preventing suboptimal execution plans&#8221;. In there, towards the end, was a gem, which illustrated how to get a sql to pick a different execution plan (preferably generated by a modified version of the sql, hinted to pick a better plan), without actually modifying the application sql. This technique uses sql plan management.</p>
<p>This blog post is just reproducing the exact same method, with the exact same example they used, with a little bit more illustration of the execution plan, hopefully to benefit folks, who have not used this procedure before, and did not attend the openworld session.</p>
<h3>The original sql</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code53'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75853"><td class="code" id="p758code53"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> connect sh<span style="color: #66cc66;">/</span>sh
Connected<span style="color: #66cc66;">.</span>
&nbsp;
SQL<span style="color: #66cc66;">&gt;</span> variable sup_id number;
SQL<span style="color: #66cc66;">&gt;</span> exec :sup_id :<span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">select</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt
<span style="color: #993333; font-weight: bold;">from</span> sales s<span style="color: #66cc66;">,</span>products p
<span style="color: #993333; font-weight: bold;">where</span> s<span style="color: #66cc66;">.</span>prod_id <span style="color: #66cc66;">=</span> p<span style="color: #66cc66;">.</span>prod_id
<span style="color: #993333; font-weight: bold;">and</span> p<span style="color: #66cc66;">.</span>supplier_id <span style="color: #66cc66;">=</span> :sup_id
<span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> p<span style="color: #66cc66;">.</span>prod_name
<span style="color: #66cc66;">/</span> 
&nbsp;
Envoy External 6X CD<span style="color: #66cc66;">-</span>ROM			    <span style="color: #cc66cc;">645586.12</span>
Model SM26273 Black Ink Cartridge		    <span style="color: #cc66cc;">617732.28</span>
Model K8822S Cordless Phone Battery		    <span style="color: #cc66cc;">582640.54</span>
Bounce						    <span style="color: #cc66cc;">244595.65</span>
Smash up Boxing 				    <span style="color: #cc66cc;">260436.75</span>
Comic Book Heroes				     <span style="color: #cc66cc;">101214.6</span></pre></td></tr></table></div>

<h3>The original Plan</h3>
<p>Note the full table scan on the products table</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code54'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75854"><td class="code" id="p758code54"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> <span style="color: #993333; font-weight: bold;">table</span> <span style="color: #66cc66;">&#40;</span>dbms_xplan<span style="color: #66cc66;">.</span>display_cursor<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'TYPICAL'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">/</span>
  <span style="color: #cc66cc;">2</span>
SQL_ID	fmjmws8askq3j<span style="color: #66cc66;">,</span> child number <span style="color: #cc66cc;">0</span>
<span style="color: #808080; font-style: italic;">-------------------------------------</span>
<span style="color: #993333; font-weight: bold;">select</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt <span style="color: #993333; font-weight: bold;">from</span> sales s<span style="color: #66cc66;">,</span>products p <span style="color: #993333; font-weight: bold;">where</span>
s<span style="color: #66cc66;">.</span>prod_id <span style="color: #66cc66;">=</span> p<span style="color: #66cc66;">.</span>prod_id <span style="color: #993333; font-weight: bold;">and</span> p<span style="color: #66cc66;">.</span>supplier_id <span style="color: #66cc66;">=</span> :sup_id <span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> p<span style="color: #66cc66;">.</span>prod_name
&nbsp;
Plan hash value: <span style="color: #cc66cc;">504757596</span>
&nbsp;
<span style="color: #808080; font-style: italic;">----------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span> Id  <span style="color: #66cc66;">|</span> Operation		<span style="color: #66cc66;">|</span> Name	   <span style="color: #66cc66;">|</span> Rows  <span style="color: #66cc66;">|</span> Bytes <span style="color: #66cc66;">|</span> Cost <span style="color: #66cc66;">&#40;</span>%CPU<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> Time	   <span style="color: #66cc66;">|</span> Pstart<span style="color: #66cc66;">|</span> Pstop <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">----------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">SELECT</span> STATEMENT	<span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">587</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>  HASH <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span>		<span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">71</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">3550</span> <span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">587</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:08 <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">|</span>   HASH <span style="color: #993333; font-weight: bold;">JOIN</span>		<span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">3600</span> <span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">586</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:08 <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">|</span>    <span style="color: #993333; font-weight: bold;">VIEW</span> 		<span style="color: #66cc66;">|</span> VW_GBC_5 <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">1224</span> <span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">583</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">|</span>     HASH <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span>	<span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">648</span> <span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">583</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">5</span> <span style="color: #66cc66;">|</span>      PARTITION RANGE <span style="color: #993333; font-weight: bold;">ALL</span><span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>   918K<span style="color: #66cc66;">|</span>  8075K<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">533</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">28</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">|</span>       <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS <span style="color: #993333; font-weight: bold;">FULL</span> <span style="color: #66cc66;">|</span> SALES    <span style="color: #66cc66;">|</span>   918K<span style="color: #66cc66;">|</span>  8075K<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">533</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">28</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">7</span> <span style="color: #66cc66;">|</span>    <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS <span style="color: #993333; font-weight: bold;">FULL</span>	<span style="color: #66cc66;">|</span> PRODUCTS <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">2376</span> <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">3</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:01 <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">----------------------------------------------------------------------------------------------------</span>
&nbsp;
Predicate Information <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">identified</span> <span style="color: #993333; font-weight: bold;">by</span> operation id<span style="color: #66cc66;">&#41;</span>:
<span style="color: #808080; font-style: italic;">---------------------------------------------------</span>
&nbsp;
   <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">-</span> access<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ITEM_1&quot;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;P&quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;PROD_ID&quot;</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #cc66cc;">7</span> <span style="color: #66cc66;">-</span> filter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;P&quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;SUPPLIER_ID&quot;</span><span style="color: #66cc66;">=</span>:SUP_ID<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #cc66cc;">26</span> rows selected<span style="color: #66cc66;">.</span></pre></td></tr></table></div>

<h3>Create the plan baseline for this sql</h3>
<p>Note that we are using the sql_id we got from the output of dbms_xplan in the previous step.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code55'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75855"><td class="code" id="p758code55"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> variable cnt number;
SQL<span style="color: #66cc66;">&gt;</span> execute :cnt :<span style="color: #66cc66;">=</span> dbms_spm<span style="color: #66cc66;">.</span>load_plans_from_cursor_cache<span style="color: #66cc66;">&#40;</span>sql_id<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'fmjmws8askq3j'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
PL<span style="color: #66cc66;">/</span>SQL procedure successfully completed<span style="color: #66cc66;">.</span></pre></td></tr></table></div>

<h3>Verify that the plan baseline was created by checking dba_sql_plan_baselines (Notice that the plan is enabled by default when you created it)</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code56'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75856"><td class="code" id="p758code56"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">select</span> sql_handle<span style="color: #66cc66;">,</span>sql_text<span style="color: #66cc66;">,</span>plan_name<span style="color: #66cc66;">,</span>enabled
<span style="color: #993333; font-weight: bold;">from</span>
dba_sql_plan_baselines
<span style="color: #993333; font-weight: bold;">where</span>
sql_text <span style="color: #993333; font-weight: bold;">like</span> <span style="color: #ff0000;">'%select p.prod_name%'</span>  <span style="color: #cc66cc;">2</span>    <span style="color: #cc66cc;">3</span>    <span style="color: #cc66cc;">4</span>    <span style="color: #cc66cc;">5</span>
  <span style="color: #cc66cc;">6</span>  <span style="color: #66cc66;">/</span>
&nbsp;
SQL_10ed3803a09c8fe1	       <span style="color: #993333; font-weight: bold;">select</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt     SQL_PLAN_11v9s0fh9t3z1c47b6be0 YES
			       <span style="color: #993333; font-weight: bold;">from</span> sales s<span style="color: #66cc66;">,</span>products p
			       <span style="color: #993333; font-weight: bold;">where</span> s<span style="color: #66cc66;">.</span>prod_i</pre></td></tr></table></div>

<h3>Disable the original plan baseline from being used. (Since we&#8217;d be substituting this with a new hinted plan)</h3>
<p>Note that we are using the plan_name and sql_handle that we got from the previous query.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code57'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75857"><td class="code" id="p758code57"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> exec :cnt :<span style="color: #66cc66;">=</span> dbms_spm<span style="color: #66cc66;">.</span>alter_sql_plan_baseline<span style="color: #66cc66;">&#40;</span>sql_handle <span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'SQL_10ed3803a09c8fe1'</span><span style="color: #66cc66;">,-</span>
					      plan_name <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">'SQL_PLAN_11v9s0fh9t3z1c47b6be0'</span><span style="color: #66cc66;">,-</span>
					      attribute_name<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'enabled'</span><span style="color: #66cc66;">,-</span>
					      attribute_value<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'NO'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">/</span></pre></td></tr></table></div>

<h3>Check dba_sql_plan_baselines to ensure the baseline is now disabled.</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code58'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75858"><td class="code" id="p758code58"><pre class="sql" style="font-family:monospace;">  <span style="color: #cc66cc;">1</span>  <span style="color: #993333; font-weight: bold;">select</span> sql_handle<span style="color: #66cc66;">,</span>sql_text<span style="color: #66cc66;">,</span>plan_name<span style="color: #66cc66;">,</span>enabled
  <span style="color: #cc66cc;">2</span>  <span style="color: #993333; font-weight: bold;">from</span>
  <span style="color: #cc66cc;">3</span>  dba_sql_plan_baselines
  <span style="color: #cc66cc;">4</span>  <span style="color: #993333; font-weight: bold;">where</span>
  <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">*</span> sql_text <span style="color: #993333; font-weight: bold;">like</span> <span style="color: #ff0000;">'%select p.prod_name%'</span>
SQL&amp;gt; <span style="color: #66cc66;">/</span>
SQL_10ed3803a09c8fe1	       <span style="color: #993333; font-weight: bold;">select</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt     SQL_PLAN_11v9s0fh9t3z1c47b6be0 NO
			       <span style="color: #993333; font-weight: bold;">from</span> sales s<span style="color: #66cc66;">,</span>products p
			       <span style="color: #993333; font-weight: bold;">where</span> s<span style="color: #66cc66;">.</span>prod_i</pre></td></tr></table></div>

<h3>Rerun the sql with an Index Hint</h3>
<p>Note that we are using a index hint (/*+ index(p) */ , to illustrate the point that, the execution plan has changed, and now it picks an index as opposed to a full table scan from the original query. In this specific case, there is no index on the supplier_id on the table products, so it picks the primary key on the table and does a full index scan. But you can see how, hinting your queries, with the proper index names can help your query.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code59'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75859"><td class="code" id="p758code59"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #808080; font-style: italic;">/*+ index(p) */</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt
<span style="color: #993333; font-weight: bold;">from</span> sales s<span style="color: #66cc66;">,</span>products p
<span style="color: #993333; font-weight: bold;">where</span> s<span style="color: #66cc66;">.</span>prod_id <span style="color: #66cc66;">=</span> p<span style="color: #66cc66;">.</span>prod_id
<span style="color: #993333; font-weight: bold;">and</span> p<span style="color: #66cc66;">.</span>supplier_id <span style="color: #66cc66;">=</span> :sup_id
<span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> p<span style="color: #66cc66;">.</span>prod_name
<span style="color: #66cc66;">/</span>   <span style="color: #cc66cc;">2</span>    <span style="color: #cc66cc;">3</span>    <span style="color: #cc66cc;">4</span>    <span style="color: #cc66cc;">5</span>    <span style="color: #cc66cc;">6</span>
Envoy External 6X CD<span style="color: #66cc66;">-</span>ROM			    <span style="color: #cc66cc;">645586.12</span>
Model SM26273 Black Ink Cartridge		    <span style="color: #cc66cc;">617732.28</span>
Model K8822S Cordless Phone Battery		    <span style="color: #cc66cc;">582640.54</span>
Bounce						    <span style="color: #cc66cc;">244595.65</span>
Smash up Boxing 				    <span style="color: #cc66cc;">260436.75</span>
Comic Book Heroes				     <span style="color: #cc66cc;">101214.6</span>
Finding Fido					     <span style="color: #cc66cc;">78881.08</span></pre></td></tr></table></div>

<h3>Check the new execution plan</h3>
<p>Notice that the new plan uses the index products_pk on the table products.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code60'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75860"><td class="code" id="p758code60"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> <span style="color: #993333; font-weight: bold;">table</span> <span style="color: #66cc66;">&#40;</span>dbms_xplan<span style="color: #66cc66;">.</span>display_cursor<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'TYPICAL'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">/</span>  <span style="color: #cc66cc;">2</span>
SQL_ID	gtdunv6qmpqqw<span style="color: #66cc66;">,</span> child number <span style="color: #cc66cc;">0</span>
<span style="color: #808080; font-style: italic;">-------------------------------------</span>
<span style="color: #993333; font-weight: bold;">select</span> <span style="color: #808080; font-style: italic;">/*+ index(p) */</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt <span style="color: #993333; font-weight: bold;">from</span> sales
s<span style="color: #66cc66;">,</span>products p <span style="color: #993333; font-weight: bold;">where</span> s<span style="color: #66cc66;">.</span>prod_id <span style="color: #66cc66;">=</span> p<span style="color: #66cc66;">.</span>prod_id <span style="color: #993333; font-weight: bold;">and</span> p<span style="color: #66cc66;">.</span>supplier_id <span style="color: #66cc66;">=</span> :sup_id
<span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> p<span style="color: #66cc66;">.</span>prod_name
&nbsp;
Plan hash value: <span style="color: #cc66cc;">4089802669</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-------------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span> Id  <span style="color: #66cc66;">|</span> Operation		      <span style="color: #66cc66;">|</span> Name	    <span style="color: #66cc66;">|</span> Rows  <span style="color: #66cc66;">|</span> Bytes <span style="color: #66cc66;">|</span> Cost <span style="color: #66cc66;">&#40;</span>%CPU<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> Time     <span style="color: #66cc66;">|</span> Pstart<span style="color: #66cc66;">|</span> Pstop <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">-------------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">SELECT</span> STATEMENT	      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">587</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>  HASH <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span>		      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">71</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">3550</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">587</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:08 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">|</span>   HASH <span style="color: #993333; font-weight: bold;">JOIN</span>		      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">3600</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">586</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:08 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">|</span>    <span style="color: #993333; font-weight: bold;">VIEW</span> 		      <span style="color: #66cc66;">|</span> VW_GBC_5    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">1224</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">583</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">|</span>     HASH <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span>	      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">648</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">583</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">5</span> <span style="color: #66cc66;">|</span>      PARTITION RANGE <span style="color: #993333; font-weight: bold;">ALL</span>      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	918K<span style="color: #66cc66;">|</span>  8075K<span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">533</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	  <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">28</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">|</span>       <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS <span style="color: #993333; font-weight: bold;">FULL</span>       <span style="color: #66cc66;">|</span> SALES	    <span style="color: #66cc66;">|</span>	918K<span style="color: #66cc66;">|</span>  8075K<span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">533</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	  <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">28</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">7</span> <span style="color: #66cc66;">|</span>    <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #993333; font-weight: bold;">INDEX</span> ROWID<span style="color: #66cc66;">|</span> PRODUCTS    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">2376</span> <span style="color: #66cc66;">|</span>	  <span style="color: #cc66cc;">3</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:01 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">8</span> <span style="color: #66cc66;">|</span>     <span style="color: #993333; font-weight: bold;">INDEX</span> <span style="color: #993333; font-weight: bold;">FULL</span> SCAN	      <span style="color: #66cc66;">|</span> PRODUCTS_PK <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	  <span style="color: #cc66cc;">1</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:01 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">-------------------------------------------------------------------------------------------------------------</span>
&nbsp;
Predicate Information <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">identified</span> <span style="color: #993333; font-weight: bold;">by</span> operation id<span style="color: #66cc66;">&#41;</span>:
<span style="color: #808080; font-style: italic;">---------------------------------------------------</span>
&nbsp;
   <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">-</span> access<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ITEM_1&quot;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;P&quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;PROD_ID&quot;</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #cc66cc;">7</span> <span style="color: #66cc66;">-</span> filter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;P&quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;SUPPLIER_ID&quot;</span><span style="color: #66cc66;">=</span>:SUP_ID<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #cc66cc;">28</span> rows selected<span style="color: #66cc66;">.</span></pre></td></tr></table></div>

<h3>Switch the execution plan for the original, unhinted sql</h3>
<p>From the dbms_xplan output above we know the new sql_id (gtdunv6qmpqqw) and the new plan_hash_value (4089802669) (For the plan that is using an index).</p>
<p>We can then use dbms_spm to associate this new execution plan, to the sql_handle we created, for the original un-hinted sql, in the sql plan baseline. We use the new sql_id and plan_hash_value, from our hinted plan and we associate it to the sql_handle from the original query.</p>
<p>Note that the sql_handle we are using here, is the sql_handle for the original unhinted sql (We get this value from the step &#8220;Verify that the plan base line was created&#8221;) .</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code61'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75861"><td class="code" id="p758code61"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> execute :cnt :<span style="color: #66cc66;">=</span> dbms_spm<span style="color: #66cc66;">.</span>load_plans_from_cursor_cache<span style="color: #66cc66;">&#40;</span>sql_id <span style="color: #66cc66;">=&gt;</span> <span style="color: #ff0000;">'gtdunv6qmpqqw'</span><span style="color: #66cc66;">,-</span>
						      plan_hash_value <span style="color: #66cc66;">=&gt;</span> <span style="color: #cc66cc;">4089802669</span><span style="color: #66cc66;">,-</span>
						      sql_handle<span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">'SQL_10ed3803a09c8fe1'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">/</span>
&nbsp;
PL<span style="color: #66cc66;">/</span>SQL procedure successfully completed<span style="color: #66cc66;">.</span></pre></td></tr></table></div>

<h3>Check that a new plan has been added to the baseline</h3>
<p>Note that the new plan is enabled by default.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code62'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75862"><td class="code" id="p758code62"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">select</span> sql_handle<span style="color: #66cc66;">,</span>sql_text<span style="color: #66cc66;">,</span>plan_name<span style="color: #66cc66;">,</span>enabled
<span style="color: #993333; font-weight: bold;">from</span>
dba_sql_plan_baselines
<span style="color: #993333; font-weight: bold;">where</span>
sql_text <span style="color: #993333; font-weight: bold;">like</span> <span style="color: #ff0000;">'%select p.prod_name%'</span>
<span style="color: #66cc66;">/</span>  
&nbsp;
SQL_10ed3803a09c8fe1	       <span style="color: #993333; font-weight: bold;">select</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt     SQL_PLAN_11v9s0fh9t3z1c47b6be0 NO
			       <span style="color: #993333; font-weight: bold;">from</span> sales s<span style="color: #66cc66;">,</span>products p
			       <span style="color: #993333; font-weight: bold;">where</span> s<span style="color: #66cc66;">.</span>prod_i
&nbsp;
SQL_10ed3803a09c8fe1	       <span style="color: #993333; font-weight: bold;">select</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt     SQL_PLAN_11v9s0fh9t3z1d20e849e YES
			       <span style="color: #993333; font-weight: bold;">from</span> sales s<span style="color: #66cc66;">,</span>products p
			       <span style="color: #993333; font-weight: bold;">where</span> s<span style="color: #66cc66;">.</span>prod_i</pre></td></tr></table></div>

<h3>Re-Run the original sql</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code63'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75863"><td class="code" id="p758code63"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">select</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt
<span style="color: #993333; font-weight: bold;">from</span> sales s<span style="color: #66cc66;">,</span>products p
<span style="color: #993333; font-weight: bold;">where</span> s<span style="color: #66cc66;">.</span>prod_id <span style="color: #66cc66;">=</span> p<span style="color: #66cc66;">.</span>prod_id
<span style="color: #993333; font-weight: bold;">and</span> p<span style="color: #66cc66;">.</span>supplier_id <span style="color: #66cc66;">=</span> :sup_id
<span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> p<span style="color: #66cc66;">.</span>prod_name
<span style="color: #66cc66;">/</span> 
&nbsp;
Envoy External 6X CD<span style="color: #66cc66;">-</span>ROM			    <span style="color: #cc66cc;">645586.12</span>
Model SM26273 Black Ink Cartridge		    <span style="color: #cc66cc;">617732.28</span>
Model K8822S Cordless Phone Battery		    <span style="color: #cc66cc;">582640.54</span>
Bounce						    <span style="color: #cc66cc;">244595.65</span>
Smash up Boxing 				    <span style="color: #cc66cc;">260436.75</span>
Comic Book Heroes				     <span style="color: #cc66cc;">101214.6</span></pre></td></tr></table></div>

<h3>Check the new execution plan</h3>
<p>You can see that the original unhinted sql statement is now using the plan hash value of the hinted query and hence is using the primary key index on the products table (As opposed to the full table scan on the original table).</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p758code64'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p75864"><td class="code" id="p758code64"><pre class="sql" style="font-family:monospace;">SQL<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> <span style="color: #993333; font-weight: bold;">table</span> <span style="color: #66cc66;">&#40;</span>dbms_xplan<span style="color: #66cc66;">.</span>display_cursor<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'TYPICAL'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
SQL_ID	fmjmws8askq3j<span style="color: #66cc66;">,</span> child number <span style="color: #cc66cc;">1</span>
<span style="color: #808080; font-style: italic;">-------------------------------------</span>
<span style="color: #993333; font-weight: bold;">select</span> p<span style="color: #66cc66;">.</span>prod_name<span style="color: #66cc66;">,</span>sum<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">.</span>amount_sold<span style="color: #66cc66;">&#41;</span> amt <span style="color: #993333; font-weight: bold;">from</span> sales s<span style="color: #66cc66;">,</span>products p <span style="color: #993333; font-weight: bold;">where</span>
s<span style="color: #66cc66;">.</span>prod_id <span style="color: #66cc66;">=</span> p<span style="color: #66cc66;">.</span>prod_id <span style="color: #993333; font-weight: bold;">and</span> p<span style="color: #66cc66;">.</span>supplier_id <span style="color: #66cc66;">=</span> :sup_id <span style="color: #993333; font-weight: bold;">group</span> <span style="color: #993333; font-weight: bold;">by</span> p<span style="color: #66cc66;">.</span>prod_name
&nbsp;
Plan hash value: <span style="color: #cc66cc;">4089802669</span>
&nbsp;
<span style="color: #808080; font-style: italic;">-------------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span> Id  <span style="color: #66cc66;">|</span> Operation		      <span style="color: #66cc66;">|</span> Name	    <span style="color: #66cc66;">|</span> Rows  <span style="color: #66cc66;">|</span> Bytes <span style="color: #66cc66;">|</span> Cost <span style="color: #66cc66;">&#40;</span>%CPU<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> Time     <span style="color: #66cc66;">|</span> Pstart<span style="color: #66cc66;">|</span> Pstop <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">-------------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">SELECT</span> STATEMENT	      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">587</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>  HASH <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span>		      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">71</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">3550</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">587</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:08 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">|</span>   HASH <span style="color: #993333; font-weight: bold;">JOIN</span>		      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">3600</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">586</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:08 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">|</span>    <span style="color: #993333; font-weight: bold;">VIEW</span> 		      <span style="color: #66cc66;">|</span> VW_GBC_5    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">1224</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">583</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">|</span>     HASH <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span>	      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">648</span> <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">583</span>  <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">5</span> <span style="color: #66cc66;">|</span>      PARTITION RANGE <span style="color: #993333; font-weight: bold;">ALL</span>      <span style="color: #66cc66;">|</span> 	    <span style="color: #66cc66;">|</span>	918K<span style="color: #66cc66;">|</span>  8075K<span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">533</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	  <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">28</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">|</span>       <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS <span style="color: #993333; font-weight: bold;">FULL</span>       <span style="color: #66cc66;">|</span> SALES	    <span style="color: #66cc66;">|</span>	918K<span style="color: #66cc66;">|</span>  8075K<span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">533</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:07 <span style="color: #66cc66;">|</span>	  <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">28</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">7</span> <span style="color: #66cc66;">|</span>    <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #993333; font-weight: bold;">INDEX</span> ROWID<span style="color: #66cc66;">|</span> PRODUCTS    <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>  <span style="color: #cc66cc;">2376</span> <span style="color: #66cc66;">|</span>	  <span style="color: #cc66cc;">3</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:01 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">8</span> <span style="color: #66cc66;">|</span>     <span style="color: #993333; font-weight: bold;">INDEX</span> <span style="color: #993333; font-weight: bold;">FULL</span> SCAN	      <span style="color: #66cc66;">|</span> PRODUCTS_PK <span style="color: #66cc66;">|</span>	 <span style="color: #cc66cc;">72</span> <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	  <span style="color: #cc66cc;">1</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:01 <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>	    <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">-------------------------------------------------------------------------------------------------------------</span>
&nbsp;
Predicate Information <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">identified</span> <span style="color: #993333; font-weight: bold;">by</span> operation id<span style="color: #66cc66;">&#41;</span>:
<span style="color: #808080; font-style: italic;">---------------------------------------------------</span>
&nbsp;
   <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">-</span> access<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ITEM_1&quot;</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;P&quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;PROD_ID&quot;</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #cc66cc;">7</span> <span style="color: #66cc66;">-</span> filter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;P&quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;SUPPLIER_ID&quot;</span><span style="color: #66cc66;">=</span>:SUP_ID<span style="color: #66cc66;">&#41;</span>
&nbsp;
Note
<span style="color: #808080; font-style: italic;">-----</span>
   <span style="color: #66cc66;">-</span> SQL plan baseline SQL_PLAN_11v9s0fh9t3z1d20e849e used <span style="color: #993333; font-weight: bold;">for</span> this statement</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=758</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s new in Oracle Linux oow2011 a summary</title>
		<link>http://dbastreet.com/blog/?p=738</link>
		<comments>http://dbastreet.com/blog/?p=738#comments</comments>
		<pubDate>Wed, 12 Oct 2011 14:55:13 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[btrfs]]></category>
		<category><![CDATA[dtrace]]></category>
		<category><![CDATA[ksplice]]></category>
		<category><![CDATA[linux containers]]></category>
		<category><![CDATA[oracle linux]]></category>
		<category><![CDATA[unbreakable kernel version 2]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=738</guid>
		<description><![CDATA[There were some significant new features of Oracle Linux, Announced during oracle openworld 2011. Some of them were in a single slide of a presentation done by Edward Screven, who is the chief corporate Architect at Oracle. Easy to have missed. So here are some of the details of the new features. DTrace is now [...]]]></description>
			<content:encoded><![CDATA[<p>There were some significant new features of Oracle Linux, Announced during oracle openworld 2011. Some of them were in a single slide of a presentation done by Edward Screven, who is the chief corporate Architect at Oracle. Easy to have missed. So here are some of the details of the new features.</p>
<h4>DTrace is now available for Oracle Linux 6</h4>
<p>DTrace has been a favorite of Solaris users for ages. Now oracle brings the coolness and functionality of DTrace to Linux.  It provides very granular level information about cpu, memory, filesystem and network usage at each process level, in addition to system calls, arguments used etc. It is kind of sort of like strace on linux, but has very rich amount of details, with very little instrumentation overhead.</p>
<p>Wim Coekaerts , has written a <a href="http://bit.ly/r6SlPc">detailed article</a> on how to enable this functionality.</p>
<h4>Kernel upgrades can now be done while the system is running (Ksplice available since beginning of Sep 2011)</h4>
<p>This one was really not an openworld announcement (But was touched upon, in Edward Screven&#8217;s presentation) . It has been available since early september 2011. Oracle acquired a company named Ksplice in July 2011. Now Oracle Linux users can perform kernel updates without having to stop the system, or having to reboot the system.</p>
<p>Wim Coekaerts , has written a <a href="http://bit.ly/qSiIgR">detailed article</a> on this new functionality and the article has a link to a white paper on how to enable this functionality.</p>
<h4>Unbreakable Enterprise Kernel version 2 now available with major new features</h4>
<p>The Unbreakable Enterprise Kernel version 2 was released and brings with it lot of new features. Couple of the highlights are below</p>
<h5> Btrfs is now Production</h5>
<p>Btrfs stands for Better file system and/or B-Tree file system. Although existing ext3 and ext4 file systems are great, it&#8217;s kind of old technology and lacks key enterprise features. Btrfs brings new features like ability to snapshot, online defragmentation, volume growth and shrinking, checksum&#8217;s of data and metadata etc.</p>
<h5> Linux Containers</h5>
<p>Solaris has had zones and containers for a while that enables virtualization of physical Sun servers that run Solaris. Now oracle is bringing this functionality to Linux. The key difference between Linux Containers and Linux Virtual Machines (Like Oracle Virtual Machine) is that, Linux Containers can run instructions native to the core cpu without any interpretation mechanisms and hence provides good performance for the virtualized hosts.</p>
<p>There are also numerous enhancements to improve performance of oracle products on Oracle Linux, in this new release of the kernel.</p>
<p>Wim Coekaerts, has posted a good article on <a href="http://bit.ly/ob6SZo">how to get started with using the Unbreakable kernel version 2</a>.</p>
<p><a href="http://blogs.oracle.com/wim/entry/containers_on_linux"> Simple example to enable linux containers</a> .</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=738</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto DOP and calibrate_io</title>
		<link>http://dbastreet.com/blog/?p=695</link>
		<comments>http://dbastreet.com/blog/?p=695#comments</comments>
		<pubDate>Tue, 11 Oct 2011 01:38:06 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[auto dop]]></category>
		<category><![CDATA[calibrate_io]]></category>
		<category><![CDATA[parallel_degree_limit]]></category>
		<category><![CDATA[parallel_degree_policy]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=695</guid>
		<description><![CDATA[I was posed the following question by a colleague recently. I am using auto DOP in 11gr2 and I am setting parallel_degree_threshold=12. But when i execute my query, my query is still running with  a parallelism of 48 (ie it seems to be ignoring my setting for parallel_degree_threshold). The problem turned out  to be that for Auto [...]]]></description>
			<content:encoded><![CDATA[<p>I was posed the following question by a colleague recently. I am using auto DOP in 11gr2 and I am setting parallel_degree_threshold=12. But when i execute my query, my query is still running with  a parallelism of 48 (ie it seems to be ignoring my setting for parallel_degree_threshold). The problem turned out  to be that for Auto DOP to work,  you need to have dbms_workload_manager.calibrate_io run and the table resource_io_calibrate$ populated.</p>
<p>This requirement is explicitly stated in the oracle 11gr2 documentation at <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e25523/parallel002.htm#CIHEFJGC">http://download.oracle.com/docs/cd/E11882_01/server.112/e25523/parallel002.htm#CIHEFJGC</a></p>
<p>&nbsp;</p>
<p>&#8220;When PARALLEL_DEGREE_POLICY is set to AUTO, Oracle Database determines whether the statement should run in parallel based on the cost of the operations in the execution plan and the hardware characteristics. The hardware characteristics include I/O calibration statistics so these statistics must be gathered otherwise Oracle Database does not use the automatic degree policy feature.&#8221;</p>
<p>Automatic DOP, where oracle figures out the degree of parallelism to use for a given query, gets turned on by setting the initialization parameter PARALLEL_DEGREE_POLICY to either AUTO or LIMITED (When it is limited it does NOT turn on parallel query queuing and in memory parallel query). So the requirement to gather calibrate_io output is applicable to both the setting AUTO and LIMITED.</p>
<p>When you are using Auto Dop, and you want to limit the maximum parallelism that a query can get, you can use the parameter parallel_degree_limit=cpu/io/&lt;integer&gt;, to limit the DOP of a query.</p>
<p>When you create a new database using a DBCA (Database configuration assistant) template, in the new database, the calibrate_io statistics is not present. You can verify this by running  the queries below.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p695code70'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69570"><td class="code" id="p695code70"><pre class="sql" style="font-family:monospace;">SQL&amp;gt; <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> resource_io_calibrate$;
&nbsp;
no rows selected
SQL&amp;gt; <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> v$io_calibration_status;
&nbsp;
<span style="color: #993333; font-weight: bold;">STATUS</span>
<span style="color: #808080; font-style: italic;">-------------</span>
CALIBRATION_TIME
<span style="color: #808080; font-style: italic;">---------------------------------------------------------------------------</span>
<span style="color: #993333; font-weight: bold;">NOT</span> AVAILABLE</pre></td></tr></table></div>

<p>Below is an example.</p>
<ul>
<li>I have created a new table named sales_rk that has 58 million rows in it.</li>
<li>There are no indexes, or primary keys on this table.</li>
<li>The table is decorated with parallel degree DEFAULT</li>
<li>parallel_degree_policy=LIMITED</li>
<li>parallel_degree_limit=2</li>
<li>cpu_count=2</li>
<li>parallel_threads_per_cpu=2</li>
<li>At this time there are no rows in resource_io_calibrate$</li>
</ul>
<p>I ran the query &#8220;select count(*) from sales_rk&#8221;</p>
<p>I would have expected auto dop to have kicked in and parallel_degree_limit to have limited the DOP of the query to 2.</p>
<p>However that is not what happened.</p>
<p>The query ran with a DOP of 4.</p>
<p style="text-align: center;"><img class="aligncenter" title="No Auto Dop" src="http://dbastreet.com/img/pq1-a.png" alt="" width="767" height="107" /></p>
<p>So oracle just picked the default DOP (cpu_count x parallel_threads_per_cpu).</p>
<p>Further evidence that Auto DOP did not kick in can be found by examining the dbms_xplan output of the statement.</p>
<p>&nbsp;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p695code71'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69571"><td class="code" id="p695code71"><pre class="sql" style="font-family:monospace;">SQL&amp;gt; <span style="color: #993333; font-weight: bold;">select</span> count<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">from</span> sales_rk;
&nbsp;
  COUNT<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">----------</span>
  <span style="color: #cc66cc;">58805952</span>
&nbsp;
SQL&amp;gt; <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> <span style="color: #993333; font-weight: bold;">table</span><span style="color: #66cc66;">&#40;</span>dbms_xplan<span style="color: #66cc66;">.</span>display_cursor<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'TYPICAL'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
PLAN_TABLE_OUTPUT
<span style="color: #808080; font-style: italic;">--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span>
SQL_ID	1bzaqj7scjp7p<span style="color: #66cc66;">,</span> child number <span style="color: #cc66cc;">0</span>
<span style="color: #808080; font-style: italic;">-------------------------------------</span>
<span style="color: #993333; font-weight: bold;">select</span> count<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">from</span> sales_rk
&nbsp;
Plan hash value: <span style="color: #cc66cc;">2302347944</span>
&nbsp;
<span style="color: #808080; font-style: italic;">--------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span> Id  <span style="color: #66cc66;">|</span> Operation	       <span style="color: #66cc66;">|</span> Name	  <span style="color: #66cc66;">|</span> Rows  <span style="color: #66cc66;">|</span> Cost <span style="color: #66cc66;">&#40;</span>%CPU<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> Time	  <span style="color: #66cc66;">|</span>    TQ  <span style="color: #66cc66;">|</span>IN<span style="color: #66cc66;">-</span>OUT<span style="color: #66cc66;">|</span> PQ Distrib <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">--------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">SELECT</span> STATEMENT       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21544</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>  SORT AGGREGATE        <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">|</span>   PX COORDINATOR       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">|</span>    PX SEND QC <span style="color: #66cc66;">&#40;</span>RANDOM<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span> :TQ10000 <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>  Q1<span style="color: #66cc66;">,</span>00 <span style="color: #66cc66;">|</span> P<span style="color: #66cc66;">-</span>&amp;gt;S <span style="color: #66cc66;">|</span> QC <span style="color: #66cc66;">&#40;</span>RAND<span style="color: #66cc66;">&#41;</span>  <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">|</span>     SORT AGGREGATE     <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>  Q1<span style="color: #66cc66;">,</span>00 <span style="color: #66cc66;">|</span> PCWP <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">5</span> <span style="color: #66cc66;">|</span>      PX BLOCK ITERATOR <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>    58M<span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21544</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:04:<span style="color: #cc66cc;">19</span> <span style="color: #66cc66;">|</span>  Q1<span style="color: #66cc66;">,</span>00 <span style="color: #66cc66;">|</span> PCWC <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">|</span>       <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS <span style="color: #993333; font-weight: bold;">FULL</span><span style="color: #66cc66;">|</span> SALES_RK <span style="color: #66cc66;">|</span>    58M<span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21544</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:04:<span style="color: #cc66cc;">19</span> <span style="color: #66cc66;">|</span>  Q1<span style="color: #66cc66;">,</span>00 <span style="color: #66cc66;">|</span> PCWP <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">--------------------------------------------------------------------------------------------------------</span>
&nbsp;
Predicate Information <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">identified</span> <span style="color: #993333; font-weight: bold;">by</span> operation id<span style="color: #66cc66;">&#41;</span>:
<span style="color: #808080; font-style: italic;">---------------------------------------------------</span>
&nbsp;
   <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">-</span> access<span style="color: #66cc66;">&#40;</span>:Z&amp;gt;<span style="color: #66cc66;">=</span>:Z <span style="color: #993333; font-weight: bold;">AND</span> :Z<span style="color: #66cc66;">&#41;</span>
&nbsp;
Note
<span style="color: #808080; font-style: italic;">-----</span>
   <span style="color: #66cc66;">-</span> automatic DOP: skipped because of IO calibrate statistics are missing</pre></td></tr></table></div>

<p>The Note section explicitly states that Auto DOP was skipped.</p>
<p>Now to fix the situation, i ran dbms_resource_manager.calibrate_io.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p695code72'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69572"><td class="code" id="p695code72"><pre class="sql" style="font-family:monospace;">DECLARE
  lat  INTEGER;
  iops INTEGER;
  mbps INTEGER;
BEGIN
  DBMS_RESOURCE_MANAGER<span style="color: #66cc66;">.</span>CALIBRATE_IO <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">,</span> iops<span style="color: #66cc66;">,</span> mbps<span style="color: #66cc66;">,</span> lat<span style="color: #66cc66;">&#41;</span>;
end;
<span style="color: #66cc66;">/</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Beware of calibrate_io generating bad numbers for io mbps. If it does, then follow instructions in MOS note 1269321.1 to delete the contents of resource_io_calibrate$ and populate the table manually.</p>
<p>Bounce the database.</p>
<p>Check whether calibrate_io worked</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p695code73'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69573"><td class="code" id="p695code73"><pre class="sql" style="font-family:monospace;">SQL&amp;gt; l
  <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> v$io_calibration_status
SQL&amp;gt; <span style="color: #66cc66;">/</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">STATUS</span>
<span style="color: #808080; font-style: italic;">-------------</span>
CALIBRATION_TIME
<span style="color: #808080; font-style: italic;">---------------------------------------------------------------------------</span>
READY
07<span style="color: #66cc66;">-</span>OCT<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span> 05<span style="color: #66cc66;">.</span>56<span style="color: #66cc66;">.</span>40<span style="color: #66cc66;">.</span>911 PM</pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Now re-run the same query, Auto DOP kicks in, and it executes with a DOP of 2.</p>
<p style="text-align: center;"><img class="aligncenter" title="Auto Dop" src="http://dbastreet.com/img/pq2-a.png" alt="" width="766" height="104" /></p>
<p>Looking at the execution plan, confirms that Auto DOP did kick in.</p>
<p>&nbsp;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p695code74'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69574"><td class="code" id="p695code74"><pre class="sql" style="font-family:monospace;">SQL&amp;gt; <span style="color: #993333; font-weight: bold;">select</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">from</span> <span style="color: #993333; font-weight: bold;">table</span><span style="color: #66cc66;">&#40;</span>dbms_xplan<span style="color: #66cc66;">.</span>display_cursor<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'TYPICAL'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
PLAN_TABLE_OUTPUT
<span style="color: #808080; font-style: italic;">------------------------------------------------------------------------------------------------------------------------</span>
SQL_ID	1bzaqj7scjp7p<span style="color: #66cc66;">,</span> child number <span style="color: #cc66cc;">1</span>
<span style="color: #808080; font-style: italic;">-------------------------------------</span>
<span style="color: #993333; font-weight: bold;">select</span> count<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">from</span> sales_rk
&nbsp;
Plan hash value: <span style="color: #cc66cc;">2302347944</span>
&nbsp;
<span style="color: #808080; font-style: italic;">--------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span> Id  <span style="color: #66cc66;">|</span> Operation	       <span style="color: #66cc66;">|</span> Name	  <span style="color: #66cc66;">|</span> Rows  <span style="color: #66cc66;">|</span> Cost <span style="color: #66cc66;">&#40;</span>%CPU<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> Time	  <span style="color: #66cc66;">|</span>    TQ  <span style="color: #66cc66;">|</span>IN<span style="color: #66cc66;">-</span>OUT<span style="color: #66cc66;">|</span> PQ Distrib <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">--------------------------------------------------------------------------------------------------------</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">SELECT</span> STATEMENT       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">43087</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>  SORT AGGREGATE        <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">|</span>   PX COORDINATOR       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	   <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">3</span> <span style="color: #66cc66;">|</span>    PX SEND QC <span style="color: #66cc66;">&#40;</span>RANDOM<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span> :TQ10000 <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>  Q1<span style="color: #66cc66;">,</span>00 <span style="color: #66cc66;">|</span> P<span style="color: #66cc66;">-</span>&amp;gt;S <span style="color: #66cc66;">|</span> QC <span style="color: #66cc66;">&#40;</span>RAND<span style="color: #66cc66;">&#41;</span>  <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">4</span> <span style="color: #66cc66;">|</span>     SORT AGGREGATE     <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>	<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>  Q1<span style="color: #66cc66;">,</span>00 <span style="color: #66cc66;">|</span> PCWP <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">5</span> <span style="color: #66cc66;">|</span>      PX BLOCK ITERATOR <span style="color: #66cc66;">|</span>	  <span style="color: #66cc66;">|</span>    58M<span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">43087</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:08 <span style="color: #66cc66;">|</span>  Q1<span style="color: #66cc66;">,</span>00 <span style="color: #66cc66;">|</span> PCWC <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|*</span>  <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">|</span>       <span style="color: #993333; font-weight: bold;">TABLE</span> ACCESS <span style="color: #993333; font-weight: bold;">FULL</span><span style="color: #66cc66;">|</span> SALES_RK <span style="color: #66cc66;">|</span>    58M<span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">43087</span>   <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span> 00:00:08 <span style="color: #66cc66;">|</span>  Q1<span style="color: #66cc66;">,</span>00 <span style="color: #66cc66;">|</span> PCWP <span style="color: #66cc66;">|</span>	       <span style="color: #66cc66;">|</span>
<span style="color: #808080; font-style: italic;">--------------------------------------------------------------------------------------------------------</span>
&nbsp;
Predicate Information <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">identified</span> <span style="color: #993333; font-weight: bold;">by</span> operation id<span style="color: #66cc66;">&#41;</span>:
<span style="color: #808080; font-style: italic;">---------------------------------------------------</span>
&nbsp;
   <span style="color: #cc66cc;">6</span> <span style="color: #66cc66;">-</span> access<span style="color: #66cc66;">&#40;</span>:Z&amp;gt;<span style="color: #66cc66;">=</span>:Z <span style="color: #993333; font-weight: bold;">AND</span> :Z<span style="color: #66cc66;">&#41;</span>
&nbsp;
Note
<span style="color: #808080; font-style: italic;">-----</span>
   <span style="color: #66cc66;">-</span> automatic DOP: Computed Degree of Parallelism <span style="color: #993333; font-weight: bold;">is</span> <span style="color: #cc66cc;">2</span> because of degree <span style="color: #993333; font-weight: bold;">limit</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=695</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exadata smart flash log</title>
		<link>http://dbastreet.com/blog/?p=689</link>
		<comments>http://dbastreet.com/blog/?p=689#comments</comments>
		<pubDate>Tue, 04 Oct 2011 12:26:48 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Database Machine]]></category>
		<category><![CDATA[Exadata]]></category>
		<category><![CDATA[11.2.2.4.0]]></category>
		<category><![CDATA[create flash log]]></category>
		<category><![CDATA[drop flash log]]></category>
		<category><![CDATA[exadata]]></category>
		<category><![CDATA[smart flash log]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=689</guid>
		<description><![CDATA[The exadata development team has now released the exadata cell software version 11.2.2.4.0, which includes a new feature called the &#8220;Smart Flash Log&#8221;. In a nutshell, this new feature speeds up redo log writes. Exadata smart flash log uses Exadata smart flash cache as a temporary storage to provide low latency redo log writes. With [...]]]></description>
			<content:encoded><![CDATA[<p>The exadata development team has now released the exadata cell software version 11.2.2.4.0, which includes a new feature called the &#8220;Smart Flash Log&#8221;.</p>
<p>In a nutshell, this new feature speeds up redo log writes. Exadata smart flash log uses Exadata smart flash cache as a temporary storage to provide low latency redo log writes. With this new feature enabled, oracle writes both to physical disk and the flash cache simultaneously.</p>
<p>So if for some reason, flash cache writes are slow, the writes to the physical disk will provide the good response times. Similarly if the physical disk writes are slow, the flash cache writes will complete faster, providing the good response times.</p>
<p>You can use the &#8220;Create flash log&#8221;, cell command to turn this feature on. You can use the &#8220;Drop flash log&#8221; cell command to turn this feature off.</p>
<p>The exadata storage server software, users guide, has been updated with this information.</p>
<p>You have to have Bundle patch 11 (Actually it works from BP9 onwards, but BP11 is recommended) and exadata cell software 11.2.2.4.0 applied to get this functionality.</p>
<p>Please read the section &#8220;Exadata Smart Flash Logging : Flash for database logging&#8221;, in the oracle technical white paper, <a href="http://www.oracle.com/technetwork/database/exadata/exadata-smart-flash-cache-366203.pdf">Exadata smart flash cache features and the Oracle Exadata Database Machine</a>, for details.</p>
<p>Here is a video tutorial produced by Oracle Education on this topic, <a href="http://www.youtube.com/watch?v=KFTFKMnr5pc">smart flash log</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=689</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monitoring Exadata database machine with Oracle Enterprise Manager 11g</title>
		<link>http://dbastreet.com/blog/?p=674</link>
		<comments>http://dbastreet.com/blog/?p=674#comments</comments>
		<pubDate>Tue, 13 Sep 2011 23:31:07 +0000</pubDate>
		<dc:creator>Rajeev</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Database Machine]]></category>
		<category><![CDATA[Exadata]]></category>
		<category><![CDATA[gridControl]]></category>
		<category><![CDATA[cell]]></category>
		<category><![CDATA[cisco switch]]></category>
		<category><![CDATA[database machine]]></category>
		<category><![CDATA[enterprise manager]]></category>
		<category><![CDATA[exadata]]></category>
		<category><![CDATA[grid control]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://dbastreet.com/blog/?p=674</guid>
		<description><![CDATA[Oracle Enterprise manager Grid control, is hands down the best monitoring and management tool, for the oracle exadata database machine. It comes with plugins to monitor all the hardware components of the database machine, and sensible, preset thresholds for proactive monitoring. Update (Nov 2011) : Enterprise manager 12c is now available, and Certified to be [...]]]></description>
			<content:encoded><![CDATA[<p>Oracle Enterprise manager Grid control, is hands down the best monitoring and management tool, for the oracle exadata database machine. It comes with plugins to monitor all the hardware components of the database machine, and sensible, preset thresholds for proactive monitoring.</p>
<p><strong><span style="color: #ff0000;">Update (Nov 2011) :</span></strong> Enterprise manager 12c is now available, and Certified to be used with exadata. The master MOS note 1110675.1 covers the installation and configuration details.</p>
<h5>Some key points</h5>
<ul>
<li>You should use 11gR1 enterprise manager grid control for monitoring.</li>
<li>You should use 11gR1 enterprise manager agents, to monitor the targets on the database machine.</li>
<li>If you use enterprise wide monitoring tools like tivoli, openview or netcool, use snmp traps from oracle enterprise manager, to notify these monitoring tools (ie dont try to directly use snmp to monitor the exadata components. You could do this but it will be too time consuming).</li>
<li>You could potentially use 10.2.0.5 Oem, with 11g agents to monitor the dbmachine, but this is not recommended as a stable/long term solution.</li>
<li>The following components (And more) can be monitored using Enterprise Manager</li>
<ul>
<li>Databases hosts</li>
<li>Exadata Cells</li>
<li>Cisco switch</li>
<li>KVM (Keyboard, Video, Mouse)</li>
<li>ILOM Monitoring</li>
<li>Infiniband switch</li>
<li>Power distribution unit (PDU)</li>
</ul>
</ul>
<h5>You have 3 possible options to configure enterprise manager</h5>
<div>
<ul>
<li>If you have an existing 11gR1 enterprise manager grid control envrionment, you can patch it with the recommended patches and use that for monitoring the dbmachine targets.</li>
</ul>
<ul>
<li>You can setup and configure a brand new 11gR1 enterprise manager grid control environment (On a separate server) and configure it to monitor the dbmachine targets.</li>
<ul>
<li>Download the required software</li>
<ul>
<li>Weblogic server 10.3.2 (MOS Note 1106105.1, 1063112.1)</li>
<li>Jdk 64 bit (Mos Note 1063587.1)</li>
<li>11gR1 Oms from download.oracle.com</li>
</ul>
<li>Install Java and Web Logic Server (Wls)</li>
<ul>
<li>MOS Note 1063762.1</li>
</ul>
<li>Patch Web Logic Server</li>
<ul>
<li>MOS Note 1072763.1</li>
</ul>
<li>Install 11gR1 Enterprise manager Oracle Management Server (OMS)</li>
<ul>
<li>Install/Create a 11gR2 database to serve as the Enterprise Manager Repository</li>
<li>Database pre-reqs for 11.1.0.1 repository (Mos Note 1064441.1)</li>
<li>Install/Configure Oms (Mos Notes 1130958.1, 1059516.1)</li>
</ul>
<li>Patch OMS with the required patches to enable database machine monitoring</li>
<ul>
<li>Mos Note 1323298.1</li>
</ul>
</ul>
</ul>
<ul>
<li>You can use an easy install option to setup and configure an enterprise manager environment and configure the plugins.</li>
<ul>
<li>The easy install is delivered as a  patch 11852882 (EMGC setup automation kit)</li>
<li>The configuration worksheet has to be filled out properly (Before the installation) and the em.param file has to be generated.</li>
<li>Follow the instructions in the readme to do a quick install of a fully configured 11gR1 Enterprise manager installation.</li>
<li>This method helps you install/patch  and configure the full 11gR1 oms in just an few steps and is a huge time saver.</li>
</ul>
</ul>
<h5>Download the required plugins to monitor the following components</h5>
</div>
<div>Download the plugins from the enterprise manager extensions exchange</div>
<div>http://www.oracle.com/technetwork/database/exadata/index.html#plug-in (Exadata cell plugin)</div>
<div>http://www.oracle.com/technetwork/oem/grid-control/exadata-plug-in-bundle-188771.html (All the rest of the plugins)</div>
<h5>Install and Configure the Agent and the Plugins</h5>
<div>
<ul>
<li>Follow MOS Note  1110675.1 to install the agents and configure the exadata cell plugin</li>
<li><a href="http://download.oracle.com/docs/cd/E11857_01/install.111/e20086/toc.htm">Oracle Exadata Avocent MergePoint Unity Switch</a></li>
<li><a href="http://download.oracle.com/docs/cd/E11857_01/install.111/e20084/toc.htm">Oracle Exadata Cisco Switch</a></li>
<li><a href="http://download.oracle.com/docs/cd/E11857_01/install.111/e20083/toc.htm">Oracle Exadata ILOM</a></li>
<li><a href="http://download.oracle.com/docs/cd/E11857_01/install.111/e20085/toc.htm">Oracle Exadata Infiniband Switch</a></li>
<li><a href="http://download.oracle.com/docs/cd/E11857_01/install.111/e20087/toc.htm">Oracle Exadata Power Distribution Unit</a></li>
<li><a href="http://download.oracle.com/docs/cd/E11857_01/install.111/e14591/toc.htm">Oracle Exadata Storage Server</a></li>
</ul>
<div>       Additional tutorials with screenshots on configuring the plugins can be found below</div>
</div>
<div>
<ul>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5504,2">Monitor Exadata Database Machine: Agent Installation and Configuration</a></li>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5505,2">Monitor Exadata Database Machine: Configuring ASM and Database Targets</a></li>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5506,2">Monitor Exadata Database Machine: Configuring the Exadata Storage Server Plug-in</a></li>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5507,2">Monitor Exadata Database Machine: Configuring the ILOM Plug-in</a></li>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5508,2">Monitor Exadata Database Machine: Configuring the InfiniBand Switch Plug-in</a></li>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5509,2">Monitor Exadata Database Machine: Configuring the Cisco Ethernet Switch Plug-in</a></li>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5510,2">Monitor Exadata Database Machine: Configuring the Avocent KVM Switch Plug-in</a></li>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5511,2">Monitor Exadata Database Machine: Configuring User Defined Metrics for Additional Network Monitoring</a></li>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5512,2">Monitor Exadata Database Machine: Configuring Plug-ins for High Availability</a></li>
<li><a href="http://apex.oracle.com/pls/apex/f?p=44785:24:346990567800120::NO:24:P24_CONTENT_ID,P24_PREV_PAGE:5513,2">Monitor Exadata Database Machine: Creating a Dashboard for Database Machine</a></li>
</ul>
<h5>Sending SNMP traps to 3rd party monitoring tools.</h5>
</div>
<div>
<ul>
<li>Get the Mib (Management Information Base) file from your enterprise manager management server and send it to the 3rd party tool administrator (eg: openview or netcool). Follow MOS note 389585.1, to get this MIB file.</li>
<li>Then configure your notification methods and rules to send the required snmp traps to the 3rd party tool.</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://dbastreet.com/blog/?feed=rss2&#038;p=674</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

