<?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>ORACLE-BASE Blog Aggregator &#187; Jonathan Lewis</title>
	<atom:link href="http://www.oracle-base.com/aggregator/author/jonathan-lewis/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oracle-base.com/aggregator</link>
	<description>Blogs I follow...</description>
	<lastBuildDate>Mon, 06 Feb 2012 11:08:59 +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>RMOUG</title>
		<link>http://jonathanlewis.wordpress.com/2012/02/03/rmoug/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/02/03/rmoug/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 09:40:51 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8373</guid>
		<description><![CDATA[Just a quick reminder that the Rocky Mountain Oracle User Group Training days are just eleven days away. It&#8217;s one of the best Oracle events I&#8217;ve attended, and I&#8217;ll be there again this year. There are plenty of good speakers and interesting presentations on a wide range of topics &#8211; and if you&#8217;re wandering around [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#38;blog=491988&#38;post=8373&#38;subd=jonathanlewis&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a quick reminder that the Rocky Mountain Oracle User Group <em><strong><a href="http://www.rmoug.org/training.htm">Training days</a></strong></em> are just eleven days away. It&#8217;s one of the best Oracle events I&#8217;ve attended, and I&#8217;ll be there again this year. There are plenty of good speakers and <em><strong><a href="http://www.technicalconferencesolutions.com/pls/caat/caat_abstract_reports.schedule?conference_id=99">interesting presentations</a></strong></em> on a wide range of topics &#8211; and if you&#8217;re wandering around between sessions with nothing to do, I&#8217;ll be around too and will be happy to say hello and have a chat.</p>
<p>Here&#8217;s the list of things I&#8217;ve pencilled in on my timetable so far. (Some of the gaps are there because I&#8217;m doing three presentations myself, some are there because I haven&#8217;t decided what to see yet.)</p>
<table border="0" cellspacing="0" cellpadding="4">
<tbody>
<tr>
<td valign="top" width="6%">Wednesday</td>
<td valign="top" width="4%">9:15</td>
<td valign="top" width="55%">Database I/O Performance: Measuring and Planning &#8211; Alex Gorbachev, Pythian</td>
</tr>
<tr>
<td valign="top" width="6%"></td>
<td valign="top" width="4%">10:45</td>
<td valign="top" width="55%">Parallel Execution in RAC &#8211; Riyaj Shamsudeen, OraInternals</td>
</tr>
<tr>
<td valign="top" width="6%"></td>
<td valign="top" width="4%">16:00</td>
<td valign="top" width="55%">Making Sense of Big Data &#8211; Gwen Shapira, Pythian</td>
</tr>
<tr>
<td valign="top" width="6%">Thursday</td>
<td valign="top" width="4%">8:30</td>
<td valign="top" width="55%">Developing and Deploying Extremely Large Databases with Oracle 11gR2 &#8211; Daniel Morgan, Morgan&#8217;s Library</td>
</tr>
<tr>
<td valign="top" width="6%"></td>
<td valign="top" width="4%">9:45</td>
<td valign="top" width="55%">Mining the AWR Repository for Capacity Planning, Visualization, and other Real World Stuff &#8211; Karl Arao, Enkitec</td>
</tr>
<tr>
<td valign="top" width="6%"></td>
<td valign="top" width="4%">13:30</td>
<td valign="top" width="55%">Using Oracle Execution Plans for Performance Gains &#8211; Janis Griffin, Confio Software</td>
</tr>
</tbody>
</table>
<p>If nothing else catches your eye, don&#8217;t miss out the opportunity to hear Maria Colgan talking about the optimizer. She&#8217;s doing three presenations (and only one of them coincides with one of mine) and they&#8217;re all worth hearing.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8373/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8373/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8373&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/02/03/rmoug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
		<item>
		<title>Viewing Figures</title>
		<link>https://jonathanlewis.wordpress.com/2012/02/02/viewing-figures-2/</link>
		<comments>https://jonathanlewis.wordpress.com/2012/02/02/viewing-figures-2/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 15:45:41 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8206</guid>
		<description><![CDATA[It&#8217;s time for another landmark. The blog has just hit 2,500,000 views (taking three weeks less than the previous half million increment) &#8211; here&#8217;s a little breakdown on the numbers. First the top five across the lifetime of the blog: AWR / Statspack menu 40,714 Updated from time to time NOT IN 33,983 Feb 2007 Cartesian [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#38;blog=491988&#38;post=8206&#38;subd=jonathanlewis&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time for another landmark. The blog has just hit 2,500,000 views (taking three weeks less than <em><strong><a href="http://jonathanlewis.wordpress.com/2011/03/22/visitors-etc/">the previous half million increment</a></strong></em>) &#8211; here&#8217;s a little breakdown on the numbers.</p>
<p>First the top five across the lifetime of the blog:</p>
<table border="0" cellspacing="0" cellpadding="4">
<tbody>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/statspack-examples/">AWR / Statspack menu</a></td>
<td align="right" valign="top" width="5%">40,714</td>
<td valign="top" width="55%">Updated from time to time</td>
</tr>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/2007/02/25/not-in/">NOT IN</a></td>
<td align="right" valign="top" width="5%">33,983</td>
<td valign="top" width="55%">Feb 2007</td>
</tr>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/2006/12/13/cartesian-merge-join/">Cartesian Merge Join</a></td>
<td align="right" valign="top" width="5%">29,633</td>
<td valign="top" width="55%">Dec 2006</td>
</tr>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/2006/11/09/dbms_xplan-in-10g/">dbms_xplan in 10g</a></td>
<td align="right" valign="top" width="5%">28,831</td>
<td valign="top" width="55%">Dec 2006</td>
</tr>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/2007/02/11/profiles/">SQL Profiles (10g)</a></td>
<td align="right" valign="top" width="5%">21,227</td>
<td valign="top" width="55%">Feb 2007</td>
</tr>
</tbody>
</table>
<p>If we look at just the last year, the top five are:</p>
<table border="0" cellspacing="0" cellpadding="4">
<tbody>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/statspack-examples/">AWR / Statspack menu</a></td>
<td align="right" valign="top" width="5%">18,782</td>
<td valign="top" width="55%">Updated from time to time</td>
</tr>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/2007/02/25/not-in/">NOT IN</a></td>
<td align="right" valign="top" width="5%">8,916</td>
<td valign="top" width="55%">Feb 2007</td>
</tr>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/2006/11/09/dbms_xplan-in-10g/">dbms_xplan in 10g</a></td>
<td align="right" valign="top" width="5%">6,212</td>
<td valign="top" width="55%">Dec 2006</td>
</tr>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/oracle-core/">Oracle Core</a></td>
<td align="right" valign="top" width="5%">6,181</td>
<td valign="top" width="55%">Dec 2011</td>
</tr>
<tr>
<td valign="top" width="20%"><a href="http://jonathanlewis.wordpress.com/2006/11/29/analysing-statspack-pt1/">Analysing Statspack (1)</a></td>
<td align="right" valign="top" width="5%">5,924</td>
<td valign="top" width="55%">Nov 2006</td>
</tr>
</tbody>
</table>
<p>The Cartesian Merge Join has finally been pushed off the top 5 in recent history, but perhaps that&#8217;s only a temporary effect while the Addenda to Oracle Core is still fresh in people&#8217;s minds. It&#8217;s interesting to see how many old articles are still popular reading, though.</p>
<p>The other statistic of note is the number of followers the blog has, currently: 828</p>
<p>While we&#8217;re looking at numbers and success stories for the 12 months &#8211; the UKOUG annual conference reviews have just come in, and one of mine managed to score 5.83 out of 6 for &#8220;Presentation Skills&#8221; and 5.65 for content &#8211; with one commentator saying:</p>
<p style="padding-left:30px;"><em>&#8220;Jonathan Lewis is a legend in Oracle circles and now, after my first session with him as speaker, I know why! This was a really well-thought out talk with loads of great ideas and info. My only criticism is that I&#8217;d like to attend it again to pick up the bits I missed the first time!&#8221;</em></p>
<p>Don&#8217;t worry &#8211; it was the one about &#8220;Beating the Oracle Optimizer&#8221;, 60 minutes featuring seven different strategies for optimising a two-table join, and I&#8217;ll be presenting it at least a couple more times in the UK (probably 27th March and 13th June in <em><strong><a href="http://jonathanlewis.wordpress.com/public-appearances/">Manchester and Linlithgow</a></strong></em>).</p>
<p>I also won two the of<em><strong><a href="http://www.ukoug.org/what-we-offer/news/are-you-an-inspiring-presenter/"> UKOUG&#8217;s &#8220;Inspiring Presenter&#8221;</a></strong></em> awards this year. Not sure I&#8217;ll be able to do that again next year since Connor McDonald was in town this year &#8211; if you ever get a chance to hear him, make sure you don&#8217;t miss it.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8206/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8206&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://jonathanlewis.wordpress.com/2012/02/02/viewing-figures-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="https://secure.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
		<item>
		<title>Subquery Factoring</title>
		<link>http://jonathanlewis.wordpress.com/2012/02/01/subquery-factoring/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/02/01/subquery-factoring/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 17:52:23 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8293</guid>
		<description><![CDATA[It&#8217;s always worth browsing through the list of Oracle&#8217;s bug fixes each time a new release or patch comes out because it can give you clues about where to look for problems in your production release &#8211; and how to anticipate problems on the upgrade. This article is an example of a fix that I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#38;blog=491988&#38;post=8293&#38;subd=jonathanlewis&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s always worth browsing through the list of Oracle&#8217;s bug fixes each time a new release or patch comes out because it can give you clues about where to look for problems in your production release &#8211; and how to anticipate problems on the upgrade. This article is an example of a fix that I found while while looking at the note for <em><strong><a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=PATCH&amp;id=1348303.1">11.2.0.3</a></strong></em> quite recently.</p>
<p>Over the last thre or four years I&#8217;ve made <em><strong><a href="http://jonathanlewis.wordpress.com/2007/07/26/subquery-factoring-2/">several</a></strong> <strong><a href="http://jonathanlewis.wordpress.com/2010/06/29/subquery-factoring-3/">comments</a></strong></em>about how subquery factoring could result in changes in execution plans even if the <em>&#8220;factored subquery&#8221;</em> (or <em>&#8220;common table expression&#8221;</em> to use the more appropriate technical term) was moved in line. In the 11.2.0.3 bug fixes list, though, you&#8217;ll find the following bug fixes:</p>
<blockquote><p>Bug 11740670 Different execution plans with and without subquery factoring (WITH clause)<br />
Bug 9002661 Transitive predicate were not generated in WITH clause.</p></blockquote>
<p>So here&#8217;s an example that&#8217;s been sitting on my laptop for a few years, waiting for the right bug fix (it&#8217;s using my standard setup of 8KB block size, LMT with 1MB uniform extents, but not ASSM, and CPU costing disabled):</p>
<p><pre class="brush: plain; gutter: false;">
create table emp (
	dept_no		not null,
	sal,
	emp_no,
	padding,
	constraint e_pk primary key(emp_no)
)
as
select
	mod(rownum,6),
	rownum,
	rownum,
	rpad('x',60)
from
	all_objects
where
	rownum &lt;= 20000
;

-- collect stats, compute, no histograms

select
	outer.*
from
	emp outer
where
	sal &gt; 1000000
and	outer.sal &gt; (
		select
			avg(inner.sal)
 		from	emp inner
		where	inner.dept_no = outer.dept_no
	)
;

with subq as (
	select
		outer.*
	from
		emp outer
	where
		sal &gt; 1000000
	and	outer.sal &gt; (
			select
				avg(inner.sal)
 			from	emp inner
			where	inner.dept_no = outer.dept_no
		)
	)
select	*
from	subq
;

</pre></p>
<p>In 11.1.0.7 (and earlier) the first version of this query uses a simple filter subquery, and the second version inlines the factored subquery (which should, therefore, produce the same plan) but then unnests the subquery and uses <em><strong><a href="http://jonathanlewis.wordpress.com/2008/12/21/group-by/">&#8220;group by placement&#8221;</a></strong></em> to resolve the plan as a hash join followed by hash aggregation. This gives us two completely different plans:</p>
<p><pre class="brush: plain; gutter: false;">

Plan for first form of the query
------------------------------------------------------------
| Id  | Operation           | Name | Rows  | Bytes | Cost  |
------------------------------------------------------------
|   0 | SELECT STATEMENT    |      |     1 |    72 |    70 |
|*  1 |  FILTER             |      |       |       |       |
|*  2 |   TABLE ACCESS FULL | EMP  |     1 |    72 |    35 |
|   3 |   SORT AGGREGATE    |      |     1 |     8 |       |
|*  4 |    TABLE ACCESS FULL| EMP  |  3333 | 26664 |    35 |
------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter(&quot;OUTER&quot;.&quot;SAL&quot;&gt; (SELECT AVG(&quot;INNER&quot;.&quot;SAL&quot;) FROM &quot;EMP&quot;
              &quot;INNER&quot; WHERE &quot;INNER&quot;.&quot;DEPT_NO&quot;=:B1))
   2 - filter(&quot;SAL&quot;&gt;1000000)
   4 - filter(&quot;INNER&quot;.&quot;DEPT_NO&quot;=:B1)

Plan with factored subquery moved in line
-------------------------------------------------------------
| Id  | Operation            | Name | Rows  | Bytes | Cost  |
-------------------------------------------------------------
|   0 | SELECT STATEMENT     |      |     1 |    83 |    93 |
|*  1 |  FILTER              |      |       |       |       |
|   2 |   HASH GROUP BY      |      |     1 |    83 |    93 |
|*  3 |    HASH JOIN         |      |  1667 |   135K|    71 |
|*  4 |     TABLE ACCESS FULL| EMP  |     1 |    72 |    35 |
|   5 |     TABLE ACCESS FULL| EMP  | 20000 |   214K|    35 |
-------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter(&quot;OUTER&quot;.&quot;SAL&quot;&gt;AVG(&quot;INNER&quot;.&quot;SAL&quot;))
   3 - access(&quot;INNER&quot;.&quot;DEPT_NO&quot;=&quot;OUTER&quot;.&quot;DEPT_NO&quot;)
   4 - filter(&quot;SAL&quot;&gt;1000000)

</pre></p>
<p>Under 11.2.0.3, however, the first plan appears for both forms of the query.</p>
<p>On the plus side &#8211; this is good, because Oracle is now behaving consistently. On the minus side &#8211; this is bad, because someone, somewhere, is going to be the unlucky person who managed to get a good execution plan by accident because of the bugs.</p>
<p><strong>Maxim:</strong> when upgrading to 11.2.0.3, keep a close eye on any queries you&#8217;ve got that include subquery factoring &#8211; in fact, you might decide to capture SQL Baselines (without activating them) for every single one of them before doing the upgrade so that you can enforce the pre-upgrade plan if the post-upgrade plan is less efficient.</p>
<p><strong>Footnote:</strong> I haven&#8217;t finished with this example &#8211; there&#8217;s an interesting follow-up that appeared in the remainder of my test code when I hinted the subquery into materialization. But that&#8217;s a story for another day.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8293/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8293&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/02/01/subquery-factoring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
		<item>
		<title>Bug fixes</title>
		<link>https://jonathanlewis.wordpress.com/2012/01/31/bug-fixes/</link>
		<comments>https://jonathanlewis.wordpress.com/2012/01/31/bug-fixes/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 18:37:33 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8299</guid>
		<description><![CDATA[From MOS (Metalink) a search for &#8220;Patch Set &#8211; List of Bug Fixes by Problem&#8221; is a useful search, andother is &#8220;Availability and Known Issues&#8221;. Whenever you find some behaviour that looks like a bug, it&#8217;s worth checking the patch sets for the patches or release that are newer than the version that you&#8217;re running [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#38;blog=491988&#38;post=8299&#38;subd=jonathanlewis&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>From MOS (Metalink) a search for &#8220;Patch Set &#8211; List of Bug Fixes by Problem&#8221; is a useful search, andother is &#8220;Availability and Known Issues&#8221;. Whenever you find some behaviour that looks like a bug, it&#8217;s worth checking the patch sets for the patches or release that are newer than the version that you&#8217;re running &#8211; you may find that your problem is a known bug with a patch that might be back-ported.</p>
<p>For ease of reference, here are some of the results I got (sorted in reverse order of version) from the searches; you will need a MOS account to follow the links:</p>
<ul>
<li><a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=PATCH&amp;id=1348303.1">11.2.0.3 patch set bug list</a></li>
<li><a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=README&amp;id=1348336.1">11.2.0.3 known issues</a></li>
<li><a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=README&amp;id=601739.1">11.1.0.7 patch set bug list</a></li>
<li><a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=README&amp;id=738538.1">11.1.0.7 known issues</a></li>
<li><a href="http://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=README&amp;id=1088172.1">10.2.0.5 patch set bug list</a></li>
<li><a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=README&amp;id=1087991.1">10.2.0.5 known issues</a></li>
<li><a href="http://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=README&amp;id=335869.1">10.1.0.5 patch set bug list</a></li>
<li><a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=README&amp;id=356201.1">10.1.0.5 known issues</a></li>
<li><a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=README&amp;id=308894.1">9.2.0.7 patch set bug list</a> (no bug list published for 9.2.0.8)</li>
<li><a href="https://support.oracle.com/CSP/ui/flash.html#tab=KBHome(page=KBHome&amp;id=()),(page=KBNavigator&amp;id=(startIndex=1&amp;requestedFacets=587,5&amp;powerview_search=&amp;facetIdClicked=&amp;back=true&amp;filterSource=BUGS&amp;defaultSearch=true&amp;cmd=getAllNodes&amp;enterprise=true&amp;docsRequested=20&amp;clickstreamSource=Bookmark&amp;userQuery=4547809))">9.2.0.8 list of actual patches</a> (see readme for bugs fixed)</li>
<li><a href="https://support.oracle.com/CSP/main/article?cmd=show&amp;type=NOT&amp;doctype=README&amp;id=388281.1">9.2.0.8 known issues</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8299/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8299&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://jonathanlewis.wordpress.com/2012/01/31/bug-fixes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="https://secure.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
		<item>
		<title>Index Hash</title>
		<link>https://jonathanlewis.wordpress.com/2012/01/30/index-hash/</link>
		<comments>https://jonathanlewis.wordpress.com/2012/01/30/index-hash/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 18:12:19 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8178</guid>
		<description><![CDATA[You might think from the title that this little note is going to be about the index hash join &#8211; you would be half right, it&#8217;s also about how the optimizer seems to make a complete hash of dealing with index hash joins. Let&#8217;s set up a simple data set and a couple of indexes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#38;blog=491988&#38;post=8178&#38;subd=jonathanlewis&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You might think from the title that this little note is going to be about the index hash join &#8211; you would be half right, it&#8217;s also about how the optimizer seems to make a complete hash of dealing with index hash joins.</p>
<p>Let&#8217;s set up a simple data set and a couple of indexes so that we can take a closer look:</p>
<p><pre class="brush: plain; gutter: false;">
create table t1
as
with generator as (
	select	--+ materialize
		rownum id
	from dual
	connect by
		level &lt;= 10000
)
select
	rownum			id,
	mod(rownum-1,20)	flag,
	lpad(rownum,10,'0')	v10,
	lpad(rownum,20,'0')	v20,
	lpad(rownum,30,'0')	v30,
	rpad('x',100)		padding
from
	generator	v1,
	generator	v2
where
	rownum &lt;= 100000
;

-- gather stats, compute, no histograms

alter table t1 add constraint t1_pk primary key(id)
	using index (create index t1_pk on t1(id))
;

create index t1_flag on t1(flag);

create index t1_ia on t1(id, v20);
create index t1_ib on t1(id, v10);
create index t1_ic on t1(id, v30);

</pre></p>
<p>The indexing is a little unusual, but does represent the sort of thing I see from time to time. In particular, the &#8220;primary key plus one more column&#8221; can be helpful to make critical queries visit only the index and not visit the table; having three such indexes is a bit over the top. Look carefully and you&#8217;ll notice that the ia, ib, ic indexes look a little out of order compared to the v20, v10, v30 columns they are built on.</p>
<p>Now try running the following SQL with autotrace enabled:</p>
<p><pre class="brush: plain; gutter: false;">
select /*+ index_ffs(t1 t1_pk) */ count(*) from t1;
select /*+ index_ffs(t1 t1_ia) */ count(*) from t1;
select /*+ index_ffs(t1 t1_ib) */ count(*) from t1;
select /*+ index_ffs(t1 t1_ic) */ count(*) from t1;
select /*+ index_ffs(t1 t1_flag) */ count(*) from t1 where flag is not null;

</pre></p>
<p>These are the results I got from 11.2.0.3 (and this test reproduces under 10.2.0.3 and 11.1.0.7). I&#8217;ve shown the full plan for the first query, but only the critical operation with its cost for the rest of them:</p>
<p><pre class="brush: plain; gutter: false;">
-------------------------------------------------------
| Id  | Operation             | Name  | Rows  | Cost  |
-------------------------------------------------------
|   0 | SELECT STATEMENT      |       |     1 |    35 |
|   1 |  SORT AGGREGATE       |       |     1 |       |
|   2 |   INDEX FAST FULL SCAN| T1_PK |   100K|    35 |
-------------------------------------------------------

|   2 |   INDEX FAST FULL SCAN| T1_IA |   100K|    80 |
|   2 |   INDEX FAST FULL SCAN| T1_IB |   100K|    59 |
|   2 |   INDEX FAST FULL SCAN| T1_IC |   100K|   101 |

|*  2 |   INDEX FAST FULL SCAN| T1_FLAG |   100K|   292K|    31 |

</pre></p>
<p>As you might expect, the longer the &#8220;extra&#8221; column, the higher the cost. It&#8217;s an interesting little detail that the queries that didn&#8217;t need to look at a data column didn&#8217;t report a &#8220;bytes&#8221; column in the execution plan &#8211; just one clue that there&#8217;s a special optimisation for the generic &#8220;count everything&#8221; query.</p>
<p>Finally, we can get to the index hash join.</p>
<p><pre class="brush: plain; gutter: false;">
select	sum(id)
from
	t1
where
	flag = 0;
;
</pre></p>
<p>Clearly, this query could do a full tablescan, but it could do a hash join between the t1_flag index and one of the other indexes. Given that the primary key index has the lowest fast full scan cost at 35, and the index fast full scan on the t1_flag index is 31, we might hope to see an index hash join with a cost of about 66. Here&#8217;s the default plan:</p>
<p><pre class="brush: plain; gutter: false;">
-----------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost  |
-----------------------------------------------------------
|   0 | SELECT STATEMENT   |      |     1 |     8 |   380 |
|   1 |  SORT AGGREGATE    |      |     1 |     8 |       |
|*  2 |   TABLE ACCESS FULL| T1   |  5000 | 40000 |   380 |
-----------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter(&quot;FLAG&quot;=0)

</pre></p>
<p>It&#8217;s a full tablescan, with a cost of 380. So let&#8217;s hint an index hash join with the two indexes we hoped to see, and find out what happens. I added the hint <strong>/*+ index_join(t1) */</strong> and got the following execution plan:</p>
<p><pre class="brush: plain; gutter: false;">
----------------------------------------------------------------------------
| Id  | Operation               | Name             | Rows  | Bytes | Cost  |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT        |                  |     1 |     8 |   533 |
|   1 |  SORT AGGREGATE         |                  |     1 |     8 |       |
|*  2 |   VIEW                  | index$_join$_001 |  5000 | 40000 |   533 |
|*  3 |    HASH JOIN            |                  |       |       |       |
|*  4 |     INDEX RANGE SCAN    | T1_FLAG          |  5000 | 40000 |    10 |
|   5 |     INDEX FAST FULL SCAN| T1_IA            |  5000 | 40000 |   645 |
----------------------------------------------------------------------------

</pre></p>
<p>Note three anomalies:<br />
a) Oracle has obeyed the index_join directive, but it&#8217;s used the &#8220;wrong&#8221; index<br />
b) the cost of the query (533) is less than the cost of one of its operations (645 at line 5)<br />
c) the cost of an index fast full scan on t1_ia has jumped from 80 (previous test) to 645</p>
<p>So let&#8217;s add a hint to get the right index used:</p>
<p><pre class="brush: plain; gutter: false;">
select
	/*+
		qb_name(main)
		index_join(@main t1 t1_flag t1_pk)
	*/
	sum(id)
from
	t1
where
	flag = 0
;
</pre></p>
<p>This makes no difference, Oracle still uses index t1_ia instead of t1_pk. It&#8217;s only when I include an undocumented hint that Oracle does what I want:</p>
<p><pre class="brush: plain; gutter: false;">
explain plan for
select
	/*+
		qb_name(main)
		outline_leaf(@main)
		index_join(@main t1 t1_flag t1_pk)
	*/
	sum(id)
from
	t1
where
	flag = 0
;

select * from table(dbms_xplan.display(null,null,'outline'));

----------------------------------------------------------------------------
| Id  | Operation               | Name             | Rows  | Bytes | Cost  |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT        |                  |     1 |     8 |   240 |
|   1 |  SORT AGGREGATE         |                  |     1 |     8 |       |
|*  2 |   VIEW                  | index$_join$_001 |  5000 | 40000 |   240 |
|*  3 |    HASH JOIN            |                  |       |       |       |
|*  4 |     INDEX RANGE SCAN    | T1_FLAG          |  5000 | 40000 |    10 |
|   5 |     INDEX FAST FULL SCAN| T1_PK            |  5000 | 40000 |   279 |
----------------------------------------------------------------------------

Outline Data
-------------
  /*+
      BEGIN_OUTLINE_DATA
      INDEX_JOIN(@&quot;MAIN&quot; &quot;T1&quot;@&quot;MAIN&quot; (&quot;T1&quot;.&quot;FLAG&quot;) (&quot;T1&quot;.&quot;ID&quot;))
      OUTLINE(@&quot;MAIN&quot;)
      OUTLINE_LEAF(@&quot;MAIN&quot;)
      OUTLINE_LEAF(@&quot;SEL$998059AF&quot;)
      ALL_ROWS
      OPT_PARAM('_optimizer_cost_model' 'io')
      DB_VERSION('11.2.0.3')
      OPTIMIZER_FEATURES_ENABLE('11.2.0.3')
      IGNORE_OPTIM_EMBEDDED_HINTS
      END_OUTLINE_DATA
  */

Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter(&quot;FLAG&quot;=0)
   3 - access(ROWID=ROWID)
   4 - access(&quot;FLAG&quot;=0)

</pre></p>
<p>You might note that with the right index in play<br />
a) The cost of the plan is now lower than the cost of the tablescan<br />
b) The total cost of the plan is still lower than the cost of the fast full scan<br />
c) The cost of the fast full scan in the hash join is much higher than the cost of a standalone fast full scan</p>
<h2>Analysis</h2>
<p>I&#8217;ve said many times that I hardly ever look at a 10053 trace. The trouble is, when I do have to look at a 10053 I usually want to tell everyone how clever I&#8217;ve been; this means that I can give people the impression that the only way to solve optimizer problems is to look at 10053 traces &#8211; it&#8217;s not, but this time around it seemed like a good idea.</p>
<p>Problem 1: in the calculation for the cost of the fast full scan for an index hash join, the optimizer starts by calculating the cost of an index <strong>full scan</strong>, then adds the original cost of the <strong>fast full scan</strong> to that figure.</p>
<p>Problem 2: when considering the index hash join, the optimizer looks at the indexes in alphabetical order of name, and selects the legal candidate. This is why my tests had 3 extra candidates with three different sizes. Try dropping index t1_ia and Oracle will use t1_ib; alernatively change the name of t1_ia to t1_id and, again, Oracle will use t1_ib. The primary key didn&#8217;t have a chance, being way down the alphabet at t1_pk. (In passing, I also tried re-arranging column orders &#8211; with the same results, the anomaly is not dependent on the index starting with the important column(s)).</p>
<p>Problem 3: why is the whole smaller than the sum of its parts ? Why worry about the little detail when the big picture is smashed ?</p>
<h2>Conclusion</h2>
<p>As I pointed out, I&#8217;ve run these tests on 10.2.0.3, 11.1.0.7 and 11.2.0.3 &#8211; the index hash join arithmetic is wrong. This means the optimizer may be missing opportunities where the index hash join is a good execution path. Keep an eye open for this, you may want to hint some of your SQL (and then switch the hints into SQL Baselines, if you&#8217;re running 11g). The trouble is, if you&#8217;ve got multiple candidate indexes you may sometimes have to choose between renaming indexes (to get the right one chosen &#8220;by accident&#8221;) or using an undocumented hint (and in more complex queries you&#8217;ll have to look at the outline to find out which query blocks the hint should reference).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8178/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8178&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://jonathanlewis.wordpress.com/2012/01/30/index-hash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="https://secure.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
		<item>
		<title>Purrpetual Motion</title>
		<link>https://jonathanlewis.wordpress.com/2012/01/27/purrpetual-motion/</link>
		<comments>https://jonathanlewis.wordpress.com/2012/01/27/purrpetual-motion/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 19:19:12 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8149</guid>
		<description><![CDATA[This is a really old idea &#8211; but it&#8217;s the first time I&#8217;ve seen it illustrated.
(The obvious flaw in the concept appears  in comment 22.)
         ]]></description>
			<content:encoded><![CDATA[<p>This is a <em><strong><a href="http://whyevolutionistrue.wordpress.com/2012/01/19/perpetual-motion-machine/">really old idea</a></strong></em> &#8211; but it&#8217;s the first time I&#8217;ve seen it illustrated.</p>
<p>(The obvious flaw in the concept appears  in comment 22.)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8149/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8149/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8149/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8149&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://jonathanlewis.wordpress.com/2012/01/27/purrpetual-motion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="https://secure.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
		<item>
		<title>Ouch!</title>
		<link>https://jonathanlewis.wordpress.com/2012/01/26/ouch/</link>
		<comments>https://jonathanlewis.wordpress.com/2012/01/26/ouch/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 20:19:43 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8169</guid>
		<description><![CDATA[Here&#8217;s a set of Instance Activity stats I&#8217;ve never seen before, and I&#8217;d rather never see again. From an active standby running 11.1.0.7 on AIX: The instance has been up for about 60 hours &#8211; and 95% of the work it has done has been trying to find the commit times for transactions affecting blocks [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#38;blog=491988&#38;post=8169&#38;subd=jonathanlewis&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a set of Instance Activity stats I&#8217;ve never seen before, and I&#8217;d rather never see again. From an active standby running 11.1.0.7 on AIX:</p>
<p><pre class="brush: plain; gutter: false;">
select
        name, value
from    v$sysstat
where
        name in (
                'consistent gets - examination',
                'consistent gets',
                'session logical reads'
        )
or      name like 'transaction tables%'
;

NAME                                                                            VALUE
---------------------------------------------------------------- --------------------
session logical reads                                                 102,731,023,313
consistent gets                                                       102,716,499,376
consistent gets - examination                                          98,170,595,252
transaction tables consistent reads - undo records applied             96,590,314,116
transaction tables consistent read rollbacks                                2,621,019

5 rows selected.

</pre></p>
<p>The instance has been up for about 60 hours &#8211; and 95% of the work it has done has been trying to find the commit times for transactions affecting blocks that are in need of cleanout. If you look at the two statistics about the transaction tables (those are the things in the undo segment header blocks) you can see that the average work done to find a commit time was a massive 48,000 visits to undo blocks.</p>
<p>The solution was fairly simple &#8211; kill all the reports which had been running for the last six hours, because they were the ones that were causing a problem, while simultaneously suffering most from the problem &#8211; at the time I killed the worst offender it was managing to read about 50 blocks per minute from the database, and doing about 100,000 buffer visits to undo blocks per second.</p>
<p>You probably won&#8217;t see this every again, but if you do, a quick check is:<br />
<pre class="brush: plain; gutter: false;">
select * from v$sess_io order by consistent_changes; 
</pre><br />
Repeat a couple of times and check if any sessions are doing a <strong>very</strong> large number (viz: tens of thousands) of consistent changes per second.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8169&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://jonathanlewis.wordpress.com/2012/01/26/ouch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="https://secure.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
		<item>
		<title>Quiz Night</title>
		<link>https://jonathanlewis.wordpress.com/2012/01/19/quiz-night-16/</link>
		<comments>https://jonathanlewis.wordpress.com/2012/01/19/quiz-night-16/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 08:51:53 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8145</guid>
		<description><![CDATA[In my previous post, I made the comment: In general, if you have a three-column index that starts with the same columns in the same order as the two-column index then the three-column index will be bigger and have a higher clustering_factor. So what scenarios can you come up with that fall outside the general [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#38;blog=491988&#38;post=8145&#38;subd=jonathanlewis&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my <em><strong><a href="http://jonathanlewis.wordpress.com/2012/01/13/quiz-night-15/">previous post</a></strong></em>, I made the comment:</p>
<blockquote><p>
In general, if you have a three-column index that starts with the same columns in the same order as the two-column index then the three-column index will be bigger and have a higher <em><strong>clustering_factor</strong></em>.
</p></blockquote>
<p>So what scenarios can you come up with that fall outside the general case ?<br />
Alternatively, what argument could you put forward that justifies the general claim ?</p>
<p>I&#8217;ll try to respond to comments on this post a little more quickly than the last one, but I still have quite a lot of other comments to catch up on.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8145&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://jonathanlewis.wordpress.com/2012/01/19/quiz-night-16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="https://secure.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
		<item>
		<title>Quiz Night</title>
		<link>http://jonathanlewis.wordpress.com/2012/01/13/quiz-night-15/</link>
		<comments>http://jonathanlewis.wordpress.com/2012/01/13/quiz-night-15/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 18:41:30 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8101</guid>
		<description><![CDATA[Browsing a little history recently I came across a note I&#8217;d written about the new-style index hint. In that note I claimed that: &#8230; the index has to start with the columns (product_group, id) in that order – with preference given to an exact match, otherwise using the lowest cost index that starts the right [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#38;blog=491988&#38;post=8101&#38;subd=jonathanlewis&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Browsing a little history recently I came across a note I&#8217;d written about the <em><strong><a href="http://jonathanlewis.wordpress.com/2011/11/24/index-hints/">new-style index hint</a></strong></em>. In that note I claimed that:</p>
<blockquote><p><em><br />
&#8230; the index has to start with the columns (product_group, id) in that order – with preference given to an exact match, otherwise using the lowest cost index that starts the right way.<br />
</em></p></blockquote>
<p>On reading this statement I suddenly realised that I hadn&#8217;t actually proved (to myself, even) that if I had the indexes <em>(product_group, id)</em> and<em> (product_group, id, other_col)</em> then a two-column hint forced Oracle to use the two column index in all (legal) circumstances.</p>
<p>So, tonight&#8217;s quiz &#8211; are there any edge cases, and what easy ways can you think of to prove (or disprove) the claim for the general case.</p>
<p><strong>Footnote:</strong> you don&#8217;t have to demonstrate the method, just a brief outline of the idea will be sufficient.</p>
<h3>Update Jan 19th</h3>
<p>I&#8217;m sorry it&#8217;s taken so long to respond to this. It was a post that I pre-dated at the end of December, and I forgot that it would launch itself.</p>
<p>The most interesting comment, from my perspective, came from Valentin Nikotin &#8211; <em>&#8220;what if the index you are hinting is in another schema?&#8221;</em> Virtually every test I do is based on a single schema, I rarely use two, or more, schemas at the same time. So what if there&#8217;s a special case that somehow the hint has a precedence that assumes the indexes will be found by (in effect) querying <em>user_ind_columns</em> rather than <em>all_ind_columns</em> ? I wouldn&#8217;t expect this to be the case &#8211; but when you&#8217;re trying to do pre-emptive trouble-shooting it&#8217;s this type of case (i.e. &#8220;nobody does that sort of thing&#8221;) that you can easily overlook.</p>
<p>The other responents came up with the type of thing that I would call the correct strategy. We need to start with an SQL statement that uses the three-column index by default and uses the two-column index only when it&#8217;s hinted. Of course, if we can examine the 10053 trace and see the change, especially the restriction to the two-column index explicitly being labelled with something like &#8220;index demanded by user hint&#8221;, then we can be pretty confident that the interpretation is correct.</p>
<p>The question then is, how can we construct a suitable demonstration.</p>
<p>In general, if you have a three-column index that starts with the same columns in the same order as the two-column index then the three-column index will be bigger and have a higher <em><strong>clustering_factor</strong></em> so, from a purely arithmetic perspective, it will be less desirable than the two column index except for one special class of queries. Consider a query of the form:</p>
<p><pre class="brush: plain;">
select  col3
from    t1
where   col1 = {constant}
and     col2 = {constant}
</pre></p>
<p>With a suitable three-column index this query can be answered from completely within the index, with only the first two columns Oracle has to visit the table. So if we ensure that there are several rows scattered around the table we can be confident (in the general case) that the optimizer will see that the three-column query has a lower cost than the two-column query.</p>
<p>I don&#8217;t need to set up the model for you &#8211; Charles Hooper has already done the work.</p>
<p><strong>Footnote 2: </strong><br />
Following Valentin Nikotin&#8217;s comment, you might like to consider that any reports you currently run against the <em><strong>user_indexes</strong></em> and <em><strong>user_ind_columns</strong></em> views (and their partition-related equivalents) should be run against the <em><strong>all_indexes</strong></em> and <em><strong>all_ind_columns</strong></em> views with a restriction of the form: <em>&#8220;table_owner = user&#8221;</em>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8101&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jonathanlewis.wordpress.com/2012/01/13/quiz-night-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://0.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
		<item>
		<title>ASH</title>
		<link>https://jonathanlewis.wordpress.com/2012/01/11/ash/</link>
		<comments>https://jonathanlewis.wordpress.com/2012/01/11/ash/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 20:06:52 +0000</pubDate>
		<dc:creator>Jonathan Lewis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=8126</guid>
		<description><![CDATA[You may have noticed that I&#8217;m having a little trouble keeping up to date on the blog at the moment &#8211; I know I&#8217;ve got several comments on Oracle Core to respond to but haven&#8217;t had time to look at them yet. Very briefly, though, I thought I&#8217;d point to a note that Doug Burns [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&#38;blog=491988&#38;post=8126&#38;subd=jonathanlewis&#38;ref=&#38;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You may have noticed that I&#8217;m having a little trouble keeping up to date on the blog at the moment &#8211; I know I&#8217;ve got several comments on Oracle Core to respond to but haven&#8217;t had time to look at them yet. Very briefly, though, I thought I&#8217;d point to a note that Doug Burns has just posted about John Beresniewicz&#8217;s presentation one &#8220;outliers&#8221; at the UKOUG conference.</p>
<p>Key feature: it supplies a query that could be very useful for capturing short, but nasty, events;  and has links to a couple of documents explaining what it&#8217;s trying to do and why. It&#8217;s a query that could do with more exercise on production systems so that Doug can get some feedback to JB about how effect it is, and how it could be improved.</p>
<p><em><strong><a href="http://oracledoug.com/serendipity/index.php?/archives/1669-UKOUG-2011-Ash-Outliers.html">Start here</a></strong></em>.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jonathanlewis.wordpress.com/8126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jonathanlewis.wordpress.com/8126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jonathanlewis.wordpress.com/8126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jonathanlewis.wordpress.com/8126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jonathanlewis.wordpress.com/8126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jonathanlewis.wordpress.com/8126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jonathanlewis.wordpress.com/8126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jonathanlewis.wordpress.com/8126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jonathanlewis.wordpress.com/8126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jonathanlewis.wordpress.com/8126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jonathanlewis.wordpress.com/8126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jonathanlewis.wordpress.com/8126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jonathanlewis.wordpress.com/8126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jonathanlewis.wordpress.com/8126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jonathanlewis.wordpress.com&amp;blog=491988&amp;post=8126&amp;subd=jonathanlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://jonathanlewis.wordpress.com/2012/01/11/ash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="https://secure.gravatar.com/avatar/08b4eccce68cd521b54671abb0442ae1?s=96&amp;amp;d=https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96&amp;amp;r=G" length="" type="" />
		</item>
	</channel>
</rss>

